Top Description Inners Fields Constructors Methods
org.hibernate.internal.util.collections

public Class LinkedIdentityHashMap<K, V>

extends IdentityHashMap<K, V>
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Collections, .IdentityHashMap, .LinkedHashSet, .Map, .Set, java.util.stream.Collectors

Utility IdentityHashMap implementation that maintains predictable iteration order, with special care for keys iteration efficiency, and uses reference equality (i.e. ==) in place of object-equality when comparing keys.

Note that the keySet(), values() and entrySet() methods for this class return unmodifiable collections and are only meant for iteration.

Author
Marco Belladelli

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final LinkedIdentityHashMap.ArraySet<K>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.IdentityHashMap.clear.

Implements java.util.Map.clear.

Removes all of the mappings from this map.
public Object
clone()

Overrides java.util.IdentityHashMap.clone.

Returns a shallow copy of this identity hash map: the keys and values themselves are not cloned.
public Set<Map.Entry<K, V>>
entrySet()

Overrides java.util.IdentityHashMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public Set<K>
keySet()

Overrides java.util.IdentityHashMap.keySet.

Implements java.util.Map.keySet.

Returns an identity-based set view of the keys contained in this map.
public V
put(K
the key with which the specified value is to be associated
key
,
V
the value to be associated with the specified key
value
)

Overrides java.util.IdentityHashMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this identity hash map.
public V
remove(Object
key whose mapping is to be removed from the map
key
)

Overrides java.util.IdentityHashMap.remove.

Implements java.util.Map.remove.

Removes the mapping for this key from this map if present.
public boolean
remove(Object
key with which the specified value is associated
key
,
Object
value expected to be associated with the specified key
value
)

Overrides java.util.IdentityHashMap.remove.

Overrides default java.util.Map.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.
public Collection<V>
values()

Overrides java.util.IdentityHashMap.values.

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from java.util.IdentityHashMap:
containsKeycontainsValueequalsforEachgethashCodeisEmptyputAllreplacereplaceAllsize

Field Detail

orderedKeysback to summary
private final LinkedIdentityHashMap.ArraySet<K> orderedKeys

Constructor Detail

LinkedIdentityHashMapback to summary
public LinkedIdentityHashMap()

Method Detail

clearback to summary
public void clear()

Overrides java.util.IdentityHashMap.clear.

Implements java.util.Map.clear.

Doc from java.util.IdentityHashMap.clear.

Removes all of the mappings from this map. The map will be empty after this call returns.

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.util.IdentityHashMap.clone.

Doc from java.util.IdentityHashMap.clone.

Returns a shallow copy of this identity hash map: the keys and values themselves are not cloned.

Returns:Object

a shallow copy of this map

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Overrides java.util.IdentityHashMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.IdentityHashMap.entrySet.

Returns a Set view of the mappings contained in this map. Each element in the returned set is a reference-equality-based Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear methods. It does not support the add or addAll methods.

Like the backing map, the Map.Entry objects in the set returned by this method define key and value equality as reference-equality rather than object-equality. This affects the behavior of the equals and hashCode methods of these Map.Entry objects. A reference-equality based Map.Entry e is equal to an object o if and only if o is a Map.Entry and e.getKey()==o.getKey() && e.getValue()==o.getValue(). To accommodate these equals semantics, the hashCode method returns System.identityHashCode(e.getKey()) ^ System.identityHashCode(e.getValue()). (While the keys and values are compared using reference equality, the Map.Entry objects themselves are not.)

Owing to the reference-equality-based semantics of the Map.Entry instances in the set returned by this method, it is possible that the symmetry and transitivity requirements of the Object#equals(Object) contract may be violated if any of the entries in the set is compared to a normal map entry, or if the set returned by this method is compared to a set of normal map entries (such as would be returned by a call to this method on a normal map). However, the Object.equals contract is guaranteed to hold among identity-based map entries, and among sets of such entries.

Returns:Set<Map.Entry<K, V>>

a set view of the identity-mappings contained in this map

Annotations
@Override
keySetback to summary
public Set<K> keySet()

Overrides java.util.IdentityHashMap.keySet.

Implements java.util.Map.keySet.

Doc from java.util.IdentityHashMap.keySet.

Returns an identity-based set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear methods. It does not support the add or addAll methods.

While the object returned by this method implements the Set interface, it does not obey Set's general contract. Like its backing map, the set returned by this method defines element equality as reference-equality rather than object-equality. This affects the behavior of its contains, remove, containsAll, equals, and hashCode methods.

The equals method of the returned set returns true only if the specified object is a set containing exactly the same object references as the returned set. The symmetry and transitivity requirements of the Object.equals contract may be violated if the set returned by this method is compared to a normal set. However, the Object.equals contract is guaranteed to hold among sets returned by this method.

The hashCode method of the returned set returns the sum of the identity hashcodes of the elements in the set, rather than the sum of their hashcodes. This is mandated by the change in the semantics of the equals method, in order to enforce the general contract of the Object.hashCode method among sets returned by this method.

Returns:Set<K>

an identity-based set view of the keys contained in this map

Annotations
@Override
putback to summary
public V put(K key, V value)

Overrides java.util.IdentityHashMap.put.

Implements java.util.Map.put.

Doc from java.util.IdentityHashMap.put.

Associates the specified value with the specified key in this identity hash map. If this map already contains a mapping for the key, the old value is replaced, otherwise, a new mapping is inserted into this map.

Parameters
key:K

the key with which the specified value is to be associated

value:V

the value to be associated with the specified key

Returns:V

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

Annotations
@Override
removeback to summary
public V remove(Object key)

Overrides java.util.IdentityHashMap.remove.

Implements java.util.Map.remove.

Doc from java.util.IdentityHashMap.remove.

Removes the mapping for this key from this map if present. The mapping is removed if and only if the mapping has a key k such that (key == k).

Parameters
key:Object

key whose mapping is to be removed from the map

Returns:V

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

Annotations
@Override
removeback to summary
public boolean remove(Object key, Object value)

Overrides java.util.IdentityHashMap.remove.

Overrides default java.util.Map.remove.

Doc from java.util.IdentityHashMap.remove.

Removes the entry for the specified key only if it is currently mapped to the specified value.

More formally, if this map contains a mapping from a key k to a value v such that (key == k) and (value == v), then this method removes the mapping for this key and returns true; otherwise it returns false.

Parameters
key:Object

Doc from java.util.Map.remove.

key with which the specified value is associated

value:Object

Doc from java.util.Map.remove.

value expected to be associated with the specified key

Returns:boolean

Doc from java.util.Map.remove.

true if the value was removed

Annotations
@Override
valuesback to summary
public Collection<V> values()

Overrides java.util.IdentityHashMap.values.

Implements java.util.Map.values.

Doc from java.util.IdentityHashMap.values.

Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear methods. It does not support the add or addAll methods.

While the object returned by this method implements the Collection interface, it does not obey Collection's general contract. Like its backing map, the collection returned by this method defines element equality as reference-equality rather than object-equality. This affects the behavior of its contains, remove and containsAll methods.

Returns:Collection<V>

Doc from java.util.Map.values.

a collection view of the values contained in this map

Annotations
@Override
org.hibernate.internal.util.collections back to summary

private final Class LinkedIdentityHashMap.ArraySet<E>

extends ArrayList<E>
implements Set<E>
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.util.ArrayList:
addaddaddAlladdAlladdFirstaddLastclearclonecontainsensureCapacityequalsforEachgetgetFirstgetLasthashCodeindexOfisEmptyiteratorlastIndexOflistIteratorlistIteratorremoveremoveremoveAllremoveFirstremoveIfremoveLastremoveRangereplaceAllretainAllsetsizesortspliteratorsubListtoArraytoArraytrimToSize

Constructor Detail

ArraySetback to summary
private ArraySet()