Lines Matching full:hash
41 * A framework for concurrent hash map implementations. The
43 * any methods. Use {@link Builder} to create a custom concurrent hash map
51 * <p>The resulting hash table supports full concurrency of retrievals and
64 * reflecting the state of the hash table at some point at or since the
81 * public InternalEntry<K, V> newEntry(K key, int hash,
83 * return new InternalEntry<K, V>(key, hash, null, next);
87 * return new InternalEntry<K, V>(key, original.hash, original.value, next);
100 * public int getHash(InternalEntry<K, V> entry) { return entry.hash; }
107 * final int hash;
110 * InternalEntry(K key, int hash, V value, InternalEntry<K, V> next) {
112 * this.hash = hash;
136 * Builds a custom concurrent hash map.
150 * other kind of hash table is a relatively slow operation, so, when
172 * Because placement in hash tables is essentially random, the actual
197 * Creates a new concurrent hash map backed by the given strategy.
276 * Implements behavior specific to the client's concurrent hash map
313 * @param hash of key returned by {@link #hashKey}
314 * @param next entry (used when implementing a hash bucket as a linked
318 abstract E newEntry(K key, int hash, E next);
377 * Returns a hash code for the given key.
403 * Returns the hash code that was passed to {@link Strategy#newEntry})
516 * Applies a supplemental hash function to a given hash code, which defends
517 * against poor quality hash functions. This is critical when the
518 * concurrent hash map uses power-of-two length hash tables, that otherwise
519 * encounter collisions for hash codes that do not differ in lower or upper
522 * @param h hash code
526 // using variant of single-word Wang/Jenkins hash.
535 /** The concurrent hash map implementation. */
541 * each of which itself is a concurrently readable hash table.
575 * Mask value for indexing into segments. The upper bits of a key's hash
587 * The segments, each of which is a specialized hash table
636 int hash(Object key) {
649 int hash = hash(key);
650 return segmentFor(hash).getEntry(key, hash);
657 int hash = strategy.getHash(entry);
658 return segmentFor(hash).removeEntry(entry, hash, value);
665 int hash = strategy.getHash(entry);
666 return segmentFor(hash).removeEntry(entry, hash);
683 * Returns the segment that should be used for key with given hash
685 * @param hash the hash code for the key
688 Segment segmentFor(int hash) {
689 return segments[(hash >>> segmentShift) & segmentMask];
695 * Segments are specialized versions of hash tables. This subclasses from
709 * created to replace them. This works well for hash tables
782 * Returns properly casted first entry of bin for given hash.
784 E getFirst(int hash) {
786 return table.get(hash & (table.length() - 1));
791 public E getEntry(Object key, int hash) {
794 for (E e = getFirst(hash); e != null; e = s.getNext(e)) {
795 if (s.getHash(e) != hash) {
813 V get(Object key, int hash) {
814 E entry = getEntry(key, hash);
822 boolean containsKey(Object key, int hash) {
825 for (E e = getFirst(hash); e != null; e = s.getNext(e)) {
826 if (s.getHash(e) != hash) {
870 boolean replace(K key, int hash, V oldValue, V newValue) {
874 for (E e = getFirst(hash); e != null; e = s.getNext(e)) {
876 if (s.getHash(e) == hash && entryKey != null
898 V replace(K key, int hash, V newValue) {
902 for (E e = getFirst(hash); e != null; e = s.getNext(e)) {
904 if (s.getHash(e) == hash && entryKey != null
924 V put(K key, int hash, V value, boolean onlyIfAbsent) {
934 int index = hash & (table.length() - 1);
941 if (s.getHash(e) == hash && entryKey != null
959 E newEntry = s.newEntry(key, hash, first);
1042 V remove(Object key, int hash) {
1048 int index = hash & (table.length() - 1);
1053 if (s.getHash(e) == hash && entryKey != null
1081 boolean remove(Object key, int hash, Object value) {
1087 int index = hash & (table.length() - 1);
1092 if (s.getHash(e) == hash && entryKey != null
1125 public boolean removeEntry(E entry, int hash, V value) {
1131 int index = hash & (table.length() - 1);
1135 if (s.getHash(e) == hash && entry.equals(e)) {
1167 public boolean removeEntry(E entry, int hash) {
1173 int index = hash & (table.length() - 1);
1177 if (s.getHash(e) == hash && entry.equals(e)) {
1330 int hash = hash(key);
1331 return segmentFor(hash).get(key, hash);
1347 int hash = hash(key);
1348 return segmentFor(hash).containsKey(key, hash);
1353 * value. Note: This method requires a full internal traversal of the hash
1437 int hash = hash(key);
1438 return segmentFor(hash).put(key, hash, value, false);
1455 int hash = hash(key);
1456 return segmentFor(hash).put(key, hash, value, true);
1485 int hash = hash(key);
1486 return segmentFor(hash).remove(key, hash);
1498 int hash = hash(key);
1499 return segmentFor(hash).remove(key, hash, value);
1517 int hash = hash(key);
1518 return segmentFor(hash).replace(key, hash, oldValue, newValue);
1535 int hash = hash(key);
1536 return segmentFor(hash).replace(key, hash, value);
2012 int hash = hash(key);
2013 Segment segment = segmentFor(hash);
2015 E entry = segment.getEntry(key, hash);
2021 entry = segment.getEntry(key, hash);
2030 int index = hash & (table.length() - 1);
2033 entry = computingStrategy.newEntry(key, hash, first);
2054 segment.removeEntry(entry, hash);
2068 segment.removeEntry(entry, hash);
2107 K key, int hash, SimpleInternalEntry<K, V> next) {
2108 return new SimpleInternalEntry<K, V>(key, hash, null, next);
2113 key, original.hash, original.value, next);
2137 return entry.hash;
2150 final int hash;
2154 K key, int hash, @Nullable V value, SimpleInternalEntry<K, V> next) {
2156 this.hash = hash;