Package org.javimmutable.collections
Interface ISetMap<K,V>
- All Superinterfaces:
ICollection<IMapEntry<K,
,ISet<V>>> InvariantCheckable
,IStreamable<IMapEntry<K,
,ISet<V>>> Iterable<IMapEntry<K,
,ISet<V>>> Mapped<K,
,ISet<V>> Serializable
,SplitableIterable<IMapEntry<K,
ISet<V>>>
- All Known Implementing Classes:
HashSetMap
,OrderedSetMap
,TemplateSetMap
,TreeSetMap
@Immutable
public interface ISetMap<K,V>
extends ICollection<IMapEntry<K,ISet<V>>>, Mapped<K,ISet<V>>, InvariantCheckable, Serializable
Interface for maps that map keys to sets of values.
-
Method Summary
Modifier and TypeMethodDescriptionSets the set associated with a specific key.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.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.default void
Processes every key/set pair in this map using the provided function.default <E extends Exception>
voidforEachThrows
(Proc2Throws<K, ISet<V>, E> proc) Processes every key/set pair in this map using the provided function.Return the set associated with key, or an empty set if no list is associated.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.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.keys()
Creates an IStreamable to access all of the Map's keys.Returns a Collector that creates a setMap of the same type as this containing all of the collected values inserted over whatever starting values this already contained.int
size()
Return the number of keys in the map.Apply the specified transform function to the Set assigned to the specified key and assign the result to the key in this map.Apply the specified transform function to the Set assigned to the specified key and assign the result to the key in this map.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 interface org.javimmutable.collections.ICollection
isEmpty, isNonEmpty
Methods inherited from interface org.javimmutable.collections.InvariantCheckable
checkInvariants
Methods inherited from interface org.javimmutable.collections.IStreamable
getSpliteratorCharacteristics, iterator, parallelStream, spliterator, stream
Methods inherited from interface org.javimmutable.collections.Mapped
find, get, getValueOr
Methods inherited from interface org.javimmutable.collections.SplitableIterable
forEachThrows, indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Method Details
-
getSet
Return the set associated with key, or an empty set if no list is associated. -
assign
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
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>
-
insert
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
Adds all of the elements of the specified Iterable to the Set for the specified key. -
insertAll
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>
-
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>
-
contains
Determines if the setmap contains the specified key. -
contains
Determines if the Set at key contains the specified value.- Returns:
- true if the Set contains the value
-
containsAll
Determines if the Set at key contains all values in the specified collection.- Returns:
- true if the Set contains the values
-
containsAll
Determines if the Set at key contains all values in the specified collection.- Returns:
- true if the Set contains the values
-
containsAny
Determines if the Set at key contains any values in the specified collection.- Returns:
- true if the Set contains a value
-
containsAny
Determines if the Set at key contains any values in the specified collection.- Returns:
- true if the Set contains a value
-
delete
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
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
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
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
Adds all values from other to the Set at key -
union
Adds all values from other to the Set at key -
intersection
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. -
intersection
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. -
intersection
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. -
intersection
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. -
transform
Apply the specified transform function to the Set assigned to the specified key and assign the result to the key in this map. If no Set is currently assigned to the key the transform function is called with an empty set.- Parameters:
key
- key holding set to be updatedtransform
- function to update the set- Returns:
- new map with update applied to set associated with key
-
transformIfPresent
Apply the specified transform function to the Set assigned to the specified key and assign the result to the key in this map. If no set is currently assigned to the key the transform function is never called and this map is returned unchanged.- Parameters:
key
- key holding set to be updatedtransform
- function to update the set- Returns:
- new map with update applied to set associated with key
-
size
int size()Return the number of keys in the map.- Specified by:
size
in interfaceICollection<K>
- Returns:
- number of values in the collection
-
deleteAll
- Specified by:
deleteAll
in interfaceICollection<K>
- Returns:
- an equivalent collection with no values
-
keys
Creates an IStreamable to access all of the Map's keys. -
values
Creates an IStreamable to access all of the specified key's set. If no set exists for key an empty IStreamable is returned.- Returns:
- a (possibly empty) IStreamable for traversing the values associated with key
-
entries
Creates an IStreamable to access all of the Map's entries. -
forEach
Processes every key/set pair in this map using the provided function. -
forEachThrows
Processes every key/set pair in this map using the provided function.- Throws:
E
-
setMapCollector
Returns a Collector that creates a setMap of the same type as this containing all of the collected values inserted over whatever starting values this already contained.
-