Commit 853d88d
committed
Auto merge of #181 - cbarrick:iter-probe, r=Amanieu
Refactor probing logic into an external iterator
This commit refactors the `RawTable::find` logic into an external iterator, and exposes a new method to create such an iterator.
My motivation was to implement a weak map on top of the raw API.
IIUC, the standard way to implement `insert` is to first call `RawTable::find` to look for an existing bucket. If one is found, replace the value. Otherwise call `RawTable::insert` to create a new bucket.
In a weak map, keys may expire. One optimization for `insert` is to reuse a bucket with an expired key. To do that, you need to keep track of expired buckets during the search stage. This isn't possible with `RawTable::find` because it only gives you access to the element, not the bucket.2 files changed
+82
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
952 | 945 | | |
953 | 946 | | |
| 947 | + | |
954 | 948 | | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | 949 | | |
959 | 950 | | |
960 | 951 | | |
| |||
1004 | 995 | | |
1005 | 996 | | |
1006 | 997 | | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
1007 | 1010 | | |
1008 | 1011 | | |
1009 | 1012 | | |
| |||
1737 | 1740 | | |
1738 | 1741 | | |
1739 | 1742 | | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
0 commit comments