Class KeyCollectionImpl.KeyMap<E,K>
java.lang.Object
org.magicwerk.brownies.collections.KeyCollectionImpl.KeyMap<E,K>
- All Implemented Interfaces:
Serializable
- Enclosing class:
KeyCollectionImpl<E>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
True to allow duplicate values if they are not null(package private) boolean
True to allow duplicate null values(package private) boolean
True to allow null keys(package private) Comparator
<K> Comparator to use for sorting (if null, elements are not sorted)(package private) boolean
True to count only number of occurrences of equal elements (can only be set on keyMap[0] storing the elements)Key storage if this is a KeyListImpl sorted by this key map, otherwise null.Key storage if not sorted.A mapper to extract keys out of element. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) Object
Add element to key map.(package private) void
(package private) boolean
containsKey
(Object key) (package private) boolean
containsValue
(Object value) (package private) boolean
containsValue
(Object key, Object value) (package private) KeyCollectionImpl.KeyMap
<E, K> copy()
(package private) KeyCollectionImpl.KeyMap
<E, K> crop()
private void
doRemoveAllByKey
(K key, KeyCollectionImpl<E> keyColl, Collection<E> coll) Removes element by key.getContainedKey
(Object key) getContainedValue
(Object value) (package private) K
(package private) boolean
iteratorValues
(KeyCollectionImpl<E> keyColl) remove
(Object key, boolean matchValue, Object value, KeyCollectionImpl keyColl) Remove element from key map.toString()
-
Field Details
-
mapper
A mapper to extract keys out of element. For the element itself, this is always an IdentMapper. -
allowNull
boolean allowNullTrue to allow null keys -
allowDuplicates
boolean allowDuplicatesTrue to allow duplicate values if they are not null -
allowDuplicatesNull
boolean allowDuplicatesNullTrue to allow duplicate null values -
comparator
Comparator<K> comparatorComparator to use for sorting (if null, elements are not sorted) -
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
Key storage if this is a KeyListImpl sorted by this key map, otherwise null. One of keysMap or keysList is used. -
count
boolean countTrue 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
KeyCollectionImpl.KeyMap<E,K> copy() -
crop
KeyCollectionImpl.KeyMap<E,K> crop() -
isPrimaryMap
boolean isPrimaryMap() -
getKey
-
containsKey
-
containsValue
-
containsValue
-
getContainedKey
-
getContainedValue
-
iteratorValues
-
addThrow
-
add
Add element to key map.- Parameters:
key
- key of elementelem
- 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
Remove element from key map.- Parameters:
key
- key of object to removematchValue
- true if value must match to remove entryvalue
- value of object to removekeyColl
- key collection which stores object- Returns:
- removed object
-
doRemoveAllByKey
Removes element by key. If there are duplicates, all elements are removed.- Parameters:
key
- key of element to removecoll
- collection to store all removed elements, null to not store themkeyMap
- key map
-
getDistinctKeys
-
toString
-