Class OrderedSetMap<K,V>
java.lang.Object
org.javimmutable.collections.setmap.OrderedSetMap<K,V>
- All Implemented Interfaces:
Serializable
,Iterable<IMapEntry<K,
,ISet<V>>> ICollection<IMapEntry<K,
,ISet<V>>> InvariantCheckable
,ISetMap<K,
,V> IStreamable<IMapEntry<K,
,ISet<V>>> Mapped<K,
,ISet<V>> SplitableIterable<IMapEntry<K,
ISet<V>>>
ISetMap
implementation that allows keys to be traversed in the same order as they
were inserted into the collection- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionSets the set associated with a specific key.void
Checks invariants of implementing class.protected void
boolean
Determines if the setmap contains the specified key.boolean
Determines if the Set at key contains the specified value.boolean
containsAll
(K key, Iterable<? extends V> values) Determines if the Set at key contains all values in the specified collection.boolean
containsAll
(K key, Iterator<? extends V> values) Determines if the Set at key contains all values in the specified collection.boolean
containsAny
(K key, Iterable<? extends V> values) Determines if the Set at key contains any values in the specified collection.boolean
containsAny
(K key, Iterator<? extends V> values) Determines if the Set at key contains any values in the specified collection.Implemented by derived classes to create a new instance of the appropriate class.Deletes the entry for the specified key (if any).Deletes the specified value from the specified key's set.Deletes the elements in other at the specified key.Deletes the elements in other at the specified key.IStreamable
<IMapEntry<K, ISet<V>>> entries()
Creates an IStreamable to access all of the Map's entries.boolean
Return a Holder containing the value associated wth the key or an empty Holder if no value is associated with the key.Return the value associated with key or null if no value is associated.Return the set associated with key, or an empty set if no list is associated.int
getValueOr
(K key, ISet<V> defaultValue) Return the value associated with key or defaultValue if no value is associated.int
hashCode()
Add value to the Set for the specified key.Add value to the Set for the specified key.Add all values to the container in some manner appropriate to the implementation.Adds all of the elements of the specified Iterable to the Set for the specified key.Adds all of the elements of the specified collection to the Set for the specified key.intersection
(K key, Iterable<? extends V> other) Removes all values from the Set at key that are not contained in the other collection.intersection
(K key, Iterator<? extends V> other) Removes all values from the Set at key that are not contained in the other collection.intersection
(K key, Set<? extends V> other) Removes all values from the Set at key that are not contained in the other collection.intersection
(K key, ISet<? extends V> other) Removes all values from the Set at key that are not contained in the other collection.boolean
isEmpty()
iterator()
Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator.keys()
Creates an IStreamable to access all of the Map's keys.static <K,
V> OrderedSetMap <K, V> of()
int
size()
Return the number of keys in the map.toString()
Adds all values from other to the Set at keyAdds all values from other to the Set at keyCreates an IStreamable to access all of the specified key's set.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.javimmutable.collections.ICollection
isNonEmpty
Methods inherited from interface org.javimmutable.collections.ISetMap
forEach, forEachThrows, insertAll, setMapCollector, transform, transformIfPresent
Methods inherited from interface org.javimmutable.collections.IStreamable
parallelStream, spliterator, stream
Methods inherited from interface org.javimmutable.collections.SplitableIterable
forEachThrows, indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Field Details
-
emptySet
-
contents
-
-
Method Details
-
of
-
checkInvariants
public void checkInvariants()Description copied from interface:InvariantCheckable
Checks invariants of implementing class.- Specified by:
checkInvariants
in interfaceInvariantCheckable
-
create
Implemented by derived classes to create a new instance of the appropriate class. -
getSet
Description copied from interface:ISetMap
Return the set associated with key, or an empty set if no list is associated. -
assign
Description copied from interface:ISetMap
Sets the set associated with a specific key. Key and value must be non-null. If the key already has a set in the map the old set is discarded and the new set is stored in its place. Returns a newISetMap
reflecting any changes. The original map is always left unchanged. -
insert
Description copied from interface:ISetMap
Add value to the Set for the specified key. Note that if the value has already been added, it will not be added again. -
insertAll
Description copied from interface:ISetMap
Adds all of the elements of the specified Iterable to the Set for the specified key. -
insertAll
Description copied from interface:ISetMap
Adds all of the elements of the specified collection to the Set for the specified key. -
insertAll
Description copied from interface:ICollection
Add all values to the container in some manner appropriate to the implementation.- Specified by:
insertAll
in interfaceICollection<K>
- Specified by:
insertAll
in interfaceISetMap<K,
V>
-
contains
Description copied from interface:ISetMap
Determines if the setmap contains the specified key. -
contains
Description copied from interface:ISetMap
Determines if the Set at key contains the specified value. -
containsAll
Description copied from interface:ISetMap
Determines if the Set at key contains all values in the specified collection.- Specified by:
containsAll
in interfaceISetMap<K,
V> - Returns:
- true if the Set contains the values
-
containsAll
Description copied from interface:ISetMap
Determines if the Set at key contains all values in the specified collection.- Specified by:
containsAll
in interfaceISetMap<K,
V> - Returns:
- true if the Set contains the values
-
containsAny
Description copied from interface:ISetMap
Determines if the Set at key contains any values in the specified collection.- Specified by:
containsAny
in interfaceISetMap<K,
V> - Returns:
- true if the Set contains a value
-
containsAny
Description copied from interface:ISetMap
Determines if the Set at key contains any values in the specified collection.- Specified by:
containsAny
in interfaceISetMap<K,
V> - Returns:
- true if the Set contains a value
-
delete
Description copied from interface:ISetMap
Deletes the entry for the specified key (if any). Returns a new map if the value was deleted or the current map if the key was not contained in the map. -
delete
Description copied from interface:ISetMap
Deletes the specified value from the specified key's set. Returns a new map if the value was deleted or the current map if the key was not contained in the map. -
deleteAll
Description copied from interface:ISetMap
Deletes the elements in other at the specified key. Returns a new map if the values were deleted or the current map if the key was not contained in the map. -
deleteAll
Description copied from interface:ISetMap
Deletes the elements in other at the specified key. Returns a new map if the values were deleted or the current map if the key was not contained in the map. -
union
Description copied from interface:ISetMap
Adds all values from other to the Set at key -
union
Description copied from interface:ISetMap
Adds all values from other to the Set at key -
intersection
Description copied from interface:ISetMap
Removes all values from the Set at key that are not contained in the other collection. If the given key is not present in the map, an empty set is added to the map.- Specified by:
intersection
in interfaceISetMap<K,
V>
-
intersection
Description copied from interface:ISetMap
Removes all values from the Set at key that are not contained in the other collection. If the given key is not present in the map, an empty set is added to the map.- Specified by:
intersection
in interfaceISetMap<K,
V>
-
intersection
Description copied from interface:ISetMap
Removes all values from the Set at key that are not contained in the other collection. If the given key is not present in the map, an empty set is added to the map.- Specified by:
intersection
in interfaceISetMap<K,
V>
-
intersection
Description copied from interface:ISetMap
Removes all values from the Set at key that are not contained in the other collection. If the given key is not present in the map, an empty set is added to the map.- Specified by:
intersection
in interfaceISetMap<K,
V>
-
size
public int size()Description copied from interface:ISetMap
Return the number of keys in the map.- Specified by:
size
in interfaceICollection<K>
- Specified by:
size
in interfaceISetMap<K,
V> - Returns:
- number of values in the collection
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceICollection<K>
- Returns:
- true only if collection contains no values
-
insert
Description copied from interface:ISetMap
Add value to the Set for the specified key. Note that if the value has already been added, it will not be added again.- Specified by:
insert
in interfaceICollection<K>
- Specified by:
insert
in interfaceISetMap<K,
V>
-
iterator
Description copied from interface:IStreamable
Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().- Specified by:
iterator
in interfaceIStreamable<K>
- Specified by:
iterator
in interfaceIterable<K>
- Specified by:
iterator
in interfaceSplitableIterable<K>
-
getSpliteratorCharacteristics
public int getSpliteratorCharacteristics()- Specified by:
getSpliteratorCharacteristics
in interfaceIStreamable<K>
- Returns:
- characteristics value used when creating Spliterators
-
keys
Description copied from interface:ISetMap
Creates an IStreamable to access all of the Map's keys. -
values
Description copied from interface:ISetMap
Creates an IStreamable to access all of the specified key's set. If no set exists for key an empty IStreamable is returned. -
get
Description copied from interface:Mapped
Return the value associated with key or null if no value is associated. Note that if null is an acceptable value to the container then this method will be ambiguous and find() should be used instead. -
getValueOr
Description copied from interface:Mapped
Return the value associated with key or defaultValue if no value is associated. Note that if defaultValue is an acceptable value to the container then this method will be ambiguous and find() should be used instead.- Specified by:
getValueOr
in interfaceMapped<K,
V> - Parameters:
key
- identifies the value to retrievedefaultValue
- value to return if no entry exists for key- Returns:
- value associated with key or defaultValue if no value is associated
-
find
Description copied from interface:Mapped
Return a Holder containing the value associated wth the key or an empty Holder if no value is associated with the key. -
deleteAll
- Specified by:
deleteAll
in interfaceICollection<K>
- Specified by:
deleteAll
in interfaceISetMap<K,
V> - Returns:
- an equivalent collection with no values
-
entries
Description copied from interface:ISetMap
Creates an IStreamable to access all of the Map's entries. -
hashCode
public int hashCode() -
equals
-
toString
-
checkSetMapInvariants
protected void checkSetMapInvariants()
-