Class KeyCollectionImpl.KeyMap<E,K>

java.lang.Object
org.magicwerk.brownies.collections.KeyCollectionImpl.KeyMap<E,K>
All Implemented Interfaces:
Serializable
Enclosing class:
KeyCollectionImpl<E>

static class KeyCollectionImpl.KeyMap<E,K> extends Object implements Serializable
  • Field Details

    • mapper

      Function<E,K> mapper
      A mapper to extract keys out of element. For the element itself, this is always an IdentMapper.
    • allowNull

      boolean allowNull
      True to allow null keys
    • allowDuplicates

      boolean allowDuplicates
      True to allow duplicate values if they are not null
    • allowDuplicatesNull

      boolean allowDuplicatesNull
      True to allow duplicate null values
    • comparator

      Comparator<K> comparator
      Comparator to use for sorting (if null, elements are not sorted)
    • keysMap

      Map<K,Object> keysMap
      Key storage if not sorted. The values are single elements or a list of elements. Note that we cannot use TreeMap as K may not be comparable. One of keysMap or keysList is used.
    • keysList

      IList<K> keysList
      Key storage if this is a KeyListImpl sorted by this key map, otherwise null. One of keysMap or keysList is used.
    • count

      boolean count
      True to count only number of occurrences of equal elements (can only be set on keyMap[0] storing the elements)
  • Constructor Details

    • KeyMap

      KeyMap()
  • Method Details

    • copy

    • crop

    • isPrimaryMap

      boolean isPrimaryMap()
    • getKey

      K getKey(E elem)
    • containsKey

      boolean containsKey(Object key)
    • containsValue

      boolean containsValue(Object key, Object value)
    • containsValue

      boolean containsValue(Object value)
    • getContainedKey

      Option<E> getContainedKey(Object key)
    • getContainedValue

      Option<E> getContainedValue(Object value)
    • iteratorValues

      Iterator<E> iteratorValues(KeyCollectionImpl<E> keyColl)
    • addThrow

      void addThrow(K key, E elem)
    • add

      Object add(K key, E elem)
      Add element to key map.
      Parameters:
      key - key of element
      elem - element
      Returns:
      SYMBOL_ADDED if element has successfully been added, SYMBOL_ERROR_NULL_KEY if a null key is not allowed, otherwise the key which is rejected because of a duplicate exception
    • remove

      Option<E> remove(Object key, boolean matchValue, Object value, KeyCollectionImpl keyColl)
      Remove element from key map.
      Parameters:
      key - key of object to remove
      matchValue - true if value must match to remove entry
      value - value of object to remove
      keyColl - key collection which stores object
      Returns:
      removed object
    • doRemoveAllByKey

      private void doRemoveAllByKey(K key, KeyCollectionImpl<E> keyColl, Collection<E> coll)
      Removes element by key. If there are duplicates, all elements are removed.
      Parameters:
      key - key of element to remove
      coll - collection to store all removed elements, null to not store them
      keyMap - key map
    • getDistinctKeys

      Set<K> getDistinctKeys()
    • toString

      public String toString()
      Overrides:
      toString in class Object