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 aLinkedHashKeyedSet
that uses the givenKeyer
to obtain keys for elements. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsv
to thisKeyedSet
; this set'sKeyer
will be called once to fetchv
's key.boolean
addAll
(Collection<? extends V> c) void
clear()
boolean
getKeyer()
Returns theKeyer
that thisKeyedSet
uses to obtain keys for elements.iterator()
Looks for and returns an element with keyk
, ornull
if none.boolean
Addsv
to thisKeyedSet
, replacing and returning an existing object with the same key asv
(if any).int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, retainAll, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, isEmpty, removeAll, retainAll, spliterator
-
Constructor Details
-
LinkedHashKeyedSet
Constructs aLinkedHashKeyedSet
that uses the givenKeyer
to obtain keys for elements.
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<K>
- Specified by:
size
in interfaceSet<K>
- Specified by:
size
in classAbstractCollection<V>
-
contains
- Specified by:
contains
in interfaceCollection<K>
- Specified by:
contains
in interfaceSet<K>
- Overrides:
contains
in classAbstractCollection<V>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<K>
- Specified by:
toArray
in interfaceSet<K>
- Overrides:
toArray
in classAbstractCollection<V>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<K>
- Specified by:
toArray
in interfaceSet<K>
- Overrides:
toArray
in classAbstractCollection<V>
-
add
Description copied from interface:KeyedSet
Addsv
to thisKeyedSet
; this set'sKeyer
will be called once to fetchv
's key. If an object equal tov
is already present in thisKeyedSet
, then this method carries out theequalBehavior
and returns the existing object. Otherwise, if an object having a key equal tov
's is already present in thisKeyedSet
, then this method carries out theconflictBehavior
and returns the existing object. Otherwise, this method addsv
to thisKeyedSet
and returns null. -
add
- Specified by:
add
in interfaceCollection<K>
- Specified by:
add
in interfaceSet<K>
- Overrides:
add
in classAbstractCollection<V>
-
remove
- Specified by:
remove
in interfaceCollection<K>
- Specified by:
remove
in interfaceSet<K>
- Overrides:
remove
in classAbstractCollection<V>
-
addAll
- Specified by:
addAll
in interfaceCollection<K>
- Specified by:
addAll
in interfaceSet<K>
- Overrides:
addAll
in classAbstractCollection<V>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<K>
- Specified by:
clear
in interfaceSet<K>
- Overrides:
clear
in classAbstractCollection<V>
-
getKeyer
Description copied from interface:KeyedSet
Returns theKeyer
that thisKeyedSet
uses to obtain keys for elements. -
replace
Description copied from interface:KeyedSet
Addsv
to thisKeyedSet
, replacing and returning an existing object with the same key asv
(if any). The existing object is replaced withv
even if it equalsv
. If no existing object is replaced, null is returned. -
lookup
Description copied from interface:KeyedSet
Looks for and returns an element with keyk
, ornull
if none.
-