Interface IListMap<K,V>

All Superinterfaces:
ICollection<IMapEntry<K,IList<V>>>, InvariantCheckable, IStreamable<IMapEntry<K,IList<V>>>, Iterable<IMapEntry<K,IList<V>>>, Mapped<K,IList<V>>, Serializable, SplitableIterable<IMapEntry<K,IList<V>>>
All Known Implementing Classes:
HashListMap, OrderedListMap, TreeListMap

@Immutable public interface IListMap<K,V> extends ICollection<IMapEntry<K,IList<V>>>, Mapped<K,IList<V>>, InvariantCheckable, Serializable
Interface for maps that map keys to lists of values.
  • Method Details

    • insertAll

      @Nonnull IListMap<K,V> insertAll(@Nonnull Iterator<? extends IMapEntry<K,IList<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 IListMap<K,V> insertAll(@Nonnull Iterable<? extends IMapEntry<K,IList<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>
    • getList

      @Nonnull IList<V> getList(@Nonnull K key)
      Return the list associated with key or an empty list if no list is associated.
      Parameters:
      key - identifies the value to retrieve
      Returns:
      list associated with key or an empty list if no value is associated
    • assign

      @Nonnull IListMap<K,V> assign(@Nonnull K key, @Nonnull IList<V> value)
      Sets the list associated with a specific key. Key and value must be non-null. If the key already has a list in the map the old list is discarded and the new list is stored in its place. Returns a new IListMap reflecting any changes. The original map is always left unchanged.
      Parameters:
      key - non-null key
      value - list of possibly null values to use for this key
      Returns:
      new map reflecting the change
    • insert

      Add key/value entry to the map, replacing any existing entry with same key.
      Specified by:
      insert in interface ICollection<K>
    • insert

      @Nonnull IListMap<K,V> insert(@Nonnull K key, @Nullable V value)
      Add value to the list for the specified key. Note that this can create duplicate values in the list.
    • insertAll

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

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

      @Nonnull IListMap<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.
      Parameters:
      key - non-null key
      Returns:
      same or different map depending on whether key was removed
    • deleteAll

      @Nonnull default IListMap<K,V> deleteAll(@Nonnull Iterable<? extends K> keys)
      Deletes the list for every key in keys. Returns a new map if the keys were deleted or the current map if the keys were contained in the map.
    • deleteAll

      @Nonnull default IListMap<K,V> deleteAll(@Nonnull Iterator<? extends K> keys)
      Deletes the list for every key in keys. Returns a new map if the keys were deleted or the current map if the keys were contained in the map.
    • transform

      default IListMap<K,V> transform(@Nonnull K key, @Nonnull Func1<IList<V>,IList<V>> transform)
      Apply the specified transform function to the List assigned to the specified key and assign the result to the key in this map. If no List is currently assigned to the key the transform function is called with an empty list.
      Parameters:
      key - key holding list to be updated
      transform - function to update the list
      Returns:
      new map with update applied to list associated with key
    • transformIfPresent

      default IListMap<K,V> transformIfPresent(@Nonnull K key, @Nonnull Func1<IList<V>,IList<V>> transform)
      Apply the specified transform function to the List assigned to the specified key and assign the result to the key in this map. If no list is currently assigned to the key the transform function is never called and this map is returned unchanged.
      Parameters:
      key - key holding list to be updated
      transform - function to update the list
      Returns:
      new map with update applied to list associated with key
    • deleteAll

      @Nonnull IListMap<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 list. If no list 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,IList<V>> proc)
      Processes every key/list pair in this map using the provided function.
    • forEachThrows

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

      @Nonnull default java.util.stream.Collector<IMapEntry<K,V>,?,IListMap<K,V>> listMapCollector()
      Returns a Collector that creates a listMap of the same type as this containing all of the collected values inserted over whatever starting values this already contained.