Finds and removes entry from the bucket linked lists in both the key-to-value direction and the value-to-key direction.
(BiEntry<K, V> entry)
| 143 | */ |
| 144 | |
| 145 | private void delete(BiEntry<K, V> entry) { |
| 146 | int keyBucket = entry.keyHash & mask; |
| 147 | BiEntry<K, V> prevBucketEntry = null; |
| 148 | for (BiEntry<K, V> bucketEntry = hashTableKToV[keyBucket]; true; bucketEntry = bucketEntry.nextInKToVBucket) { |
| 149 | if (bucketEntry == entry) { |
| 150 | if (prevBucketEntry == null) { |
| 151 | hashTableKToV[keyBucket] = entry.nextInKToVBucket; |
| 152 | } else { |
| 153 | prevBucketEntry.nextInKToVBucket = entry.nextInKToVBucket; |
| 154 | } |
| 155 | break; |
| 156 | } |
| 157 | prevBucketEntry = bucketEntry; |
| 158 | } |
| 159 | int valueBucket = entry.valueHash & mask; |
| 160 | prevBucketEntry = null; |
| 161 | for (BiEntry<K, V> bucketEntry = hashTableVToK[valueBucket]; true; bucketEntry = bucketEntry.nextInVToKBucket) { |
| 162 | if (bucketEntry == entry) { |
| 163 | if (prevBucketEntry == null) { |
| 164 | hashTableVToK[valueBucket] = entry.nextInVToKBucket; |
| 165 | } else { |
| 166 | prevBucketEntry.nextInVToKBucket = entry.nextInVToKBucket; |
| 167 | } |
| 168 | break; |
| 169 | } |
| 170 | prevBucketEntry = bucketEntry; |
| 171 | } |
| 172 | if (entry.prevInKeyInsertionOrder == null) { |
| 173 | firstInKeyInsertionOrder = entry.nextInKeyInsertionOrder; |
| 174 | } else { |
| 175 | entry.prevInKeyInsertionOrder.nextInKeyInsertionOrder = entry.nextInKeyInsertionOrder; |
| 176 | } |
| 177 | if (entry.nextInKeyInsertionOrder == null) { |
| 178 | lastInKeyInsertionOrder = entry.prevInKeyInsertionOrder; |
| 179 | } else { |
| 180 | entry.nextInKeyInsertionOrder.prevInKeyInsertionOrder = entry.prevInKeyInsertionOrder; |
| 181 | } |
| 182 | size--; |
| 183 | modCount++; |
| 184 | } |
| 185 | |
| 186 | private void insert(BiEntry<K, V> entry, @Nullable BiEntry<K, V> oldEntryForKey) { |
| 187 | int keyBucket = entry.keyHash & mask; |