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 Details

    • getSet

      @Nonnull ISet<V> getSet(@Nonnull K key)
      Return the set associated with key, or an empty set if no list is associated.
    • assign

      @Nonnull ISetMap<K,V> assign(@Nonnull K key, @Nonnull ISet<V> value)
      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 new ISetMap reflecting any changes. The original map is always left unchanged.
    • insert

      @Nonnull ISetMap<K,V> insert(@Nonnull IMapEntry<K,ISet<V>> value)
      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 interface ICollection<K>
    • insert

      @Nonnull ISetMap<K,V> insert(@Nonnull K key, @Nonnull V value)
      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

      @Nonnull default ISetMap<K,V> insertAll(@Nonnull K key, @Nonnull Iterable<? extends V> values)
      Adds all of the elements of the specified Iterable to the Set for the specified key.
    • insertAll

      @Nonnull default ISetMap<K,V> insertAll(@Nonnull K key, @Nonnull Iterator<? extends V> values)
      Adds all of the elements of the specified collection to the Set for the specified key.
    • insertAll

      @Nonnull ISetMap<K,V> insertAll(@Nonnull Iterator<? extends IMapEntry<K,ISet<V>>> iterator)
      Description copied from interface: ICollection
      Add all values to the container in some manner appropriate to the implementation.
      Specified by:
      insertAll in interface ICollection<K>
    • insertAll

      @Nonnull default ISetMap<K,V> insertAll(@Nonnull Iterable<? extends IMapEntry<K,ISet<V>>> iterable)
      Description copied from interface: ICollection
      Add all values to the container in some manner appropriate to the implementation.
      Specified by:
      insertAll in interface ICollection<K>
    • contains

      boolean contains(@Nonnull K key)
      Determines if the setmap contains the specified key.
    • contains

      boolean contains(@Nonnull K key, @Nullable V value)
      Determines if the Set at key contains the specified value.
      Returns:
      true if the Set contains the value
    • containsAll

      boolean containsAll(@Nonnull K key, @Nonnull Iterable<? extends V> values)
      Determines if the Set at key contains all values in the specified collection.
      Returns:
      true if the Set contains the values
    • containsAll

      boolean containsAll(@Nonnull K key, @Nonnull Iterator<? extends V> values)
      Determines if the Set at key contains all values in the specified collection.
      Returns:
      true if the Set contains the values
    • containsAny

      boolean containsAny(@Nonnull K key, @Nonnull Iterable<? extends V> values)
      Determines if the Set at key contains any values in the specified collection.
      Returns:
      true if the Set contains a value
    • containsAny

      boolean containsAny(@Nonnull K key, @Nonnull Iterator<? extends V> values)
      Determines if the Set at key contains any values in the specified collection.
      Returns:
      true if the Set contains a value
    • delete

      @Nonnull ISetMap<K,V> delete(@Nonnull K key)
      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

      @Nonnull ISetMap<K,V> delete(@Nonnull K key, @Nonnull V value)
      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

      @Nonnull ISetMap<K,V> deleteAll(@Nonnull K key, @Nonnull Iterable<? extends V> other)
      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

      @Nonnull ISetMap<K,V> deleteAll(@Nonnull K key, @Nonnull Iterator<? extends V> other)
      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

      @Nonnull ISetMap<K,V> union(@Nonnull K key, @Nonnull Iterable<? extends V> other)
      Adds all values from other to the Set at key
    • union

      @Nonnull ISetMap<K,V> union(@Nonnull K key, @Nonnull Iterator<? extends V> other)
      Adds all values from other to the Set at key
    • intersection

      @Nonnull ISetMap<K,V> intersection(@Nonnull K key, @Nonnull Iterable<? extends V> other)
      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

      @Nonnull ISetMap<K,V> intersection(@Nonnull K key, @Nonnull Iterator<? extends V> other)
      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

      @Nonnull ISetMap<K,V> intersection(@Nonnull K key, @Nonnull ISet<? extends V> other)
      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

      @Nonnull ISetMap<K,V> intersection(@Nonnull K key, @Nonnull Set<? extends V> other)
      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

      default ISetMap<K,V> transform(@Nonnull K key, @Nonnull Func1<ISet<V>,ISet<V>> 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 updated
      transform - function to update the set
      Returns:
      new map with update applied to set associated with key
    • transformIfPresent

      default ISetMap<K,V> transformIfPresent(@Nonnull K key, @Nonnull Func1<ISet<V>,ISet<V>> 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 never called and this map is returned unchanged.
      Parameters:
      key - key holding set to be updated
      transform - 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 interface ICollection<K>
      Returns:
      number of values in the collection
    • deleteAll

      @Nonnull ISetMap<K,V> deleteAll()
      Specified by:
      deleteAll in interface ICollection<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

      default void forEach(@Nonnull Proc2<K,ISet<V>> proc)
      Processes every key/set pair in this map using the provided function.
    • forEachThrows

      default <E extends Exception> void forEachThrows(@Nonnull Proc2Throws<K,ISet<V>,E> proc) throws E
      Processes every key/set pair in this map using the provided function.
      Throws:
      E
    • setMapCollector

      @Nonnull default java.util.stream.Collector<IMapEntry<K,V>,?,ISetMap<K,V>> 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.