Class LinkedHashKeyedSet<K,V>
java.lang.Object
java.util.AbstractCollection<V>
java.util.AbstractSet<V>
org.checkerframework.afu.scenelib.util.coll.LinkedHashKeyedSet<K,V>
- All Implemented Interfaces:
Iterable<V>,Collection<V>,Set<V>,KeyedSet<K,V>
A simple implementation of
KeyedSet backed by an insertion-order LinkedHashMap and its value collection.-
Field Summary
Fields inherited from interface org.checkerframework.afu.scenelib.util.coll.KeyedSet
IGNORE, REPLACE, THROW_EXCEPTION -
Constructor Summary
ConstructorsConstructorDescriptionLinkedHashKeyedSet(Keyer<? extends K, ? super V> keyer) Constructs aLinkedHashKeyedSetthat uses the givenKeyerto obtain keys for elements. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAddsvto thisKeyedSet; this set'sKeyerwill be called once to fetchv's key.booleanaddAll(Collection<? extends V> c) voidclear()booleangetKeyer()Returns theKeyerthat thisKeyedSetuses to obtain keys for elements.iterator()Looks for and returns an element with keyk, ornullif none.booleanAddsvto thisKeyedSet, replacing and returning an existing object with the same key asv(if any).intsize()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
containsAll, isEmpty, retainAll, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
containsAll, equals, hashCode, isEmpty, removeAll, retainAll, spliterator
-
Constructor Details
-
LinkedHashKeyedSet
Constructs aLinkedHashKeyedSetthat uses the givenKeyerto obtain keys for elements.
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<K>- Specified by:
sizein interfaceSet<K>- Specified by:
sizein classAbstractCollection<V>
-
contains
- Specified by:
containsin interfaceCollection<K>- Specified by:
containsin interfaceSet<K>- Overrides:
containsin classAbstractCollection<V>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<K>- Specified by:
toArrayin interfaceSet<K>- Overrides:
toArrayin classAbstractCollection<V>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<K>- Specified by:
toArrayin interfaceSet<K>- Overrides:
toArrayin classAbstractCollection<V>
-
add
Description copied from interface:KeyedSetAddsvto thisKeyedSet; this set'sKeyerwill be called once to fetchv's key. If an object equal tovis already present in thisKeyedSet, then this method carries out theequalBehaviorand returns the existing object. Otherwise, if an object having a key equal tov's is already present in thisKeyedSet, then this method carries out theconflictBehaviorand returns the existing object. Otherwise, this method addsvto thisKeyedSetand returns null. -
add
- Specified by:
addin interfaceCollection<K>- Specified by:
addin interfaceSet<K>- Overrides:
addin classAbstractCollection<V>
-
remove
- Specified by:
removein interfaceCollection<K>- Specified by:
removein interfaceSet<K>- Overrides:
removein classAbstractCollection<V>
-
addAll
- Specified by:
addAllin interfaceCollection<K>- Specified by:
addAllin interfaceSet<K>- Overrides:
addAllin classAbstractCollection<V>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<K>- Specified by:
clearin interfaceSet<K>- Overrides:
clearin classAbstractCollection<V>
-
getKeyer
Description copied from interface:KeyedSetReturns theKeyerthat thisKeyedSetuses to obtain keys for elements. -
replace
Description copied from interface:KeyedSetAddsvto thisKeyedSet, replacing and returning an existing object with the same key asv(if any). The existing object is replaced withveven if it equalsv. If no existing object is replaced, null is returned. -
lookup
Description copied from interface:KeyedSetLooks for and returns an element with keyk, ornullif none.
-