E
- type of elements stored in the collectionK1
- type of first keyK2
- type of second keypublic class Key2Collection<E,K1,K2> extends KeyCollectionImpl<E>
Key1List
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
Key2Collection.Builder<E,K1,K2>
Builder to construct Key2Collection instances.
|
KeyCollectionImpl.BuilderImpl<E>
Modifier | Constructor and Description |
---|---|
protected |
Key2Collection()
Protected constructor used by builder or derived collections.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<K1,E> |
asMap1()
Returns a map view to the key map.
|
java.util.Map<K2,E> |
asMap2()
Returns a map view to the key map.
|
boolean |
containsKey1(K1 key)
Checks whether an element with specified key exists.
|
boolean |
containsKey2(K2 key)
Checks whether an element with specified key exists.
|
Key2Collection<E,K1,K2> |
copy()
Returns a copy of this collection with all its elements.
|
Key2Collection<E,K1,K2> |
crop()
Returns a copy of this collection but without elements.
|
Key2Collection<E,K1,K2> |
filter(java.util.function.Predicate<? super E> filter)
Create a new collection by applying the specified filter to all elements.
|
Key2Collection<E,K1,K2> |
getAll(E elem)
Returns all equal elements.
|
Key2Collection<E,K1,K2> |
getAllByKey1(K1 key)
Returns all elements with specified key.
|
Key2Collection<E,K1,K2> |
getAllByKey2(K2 key)
Returns all elements with specified key.
|
IList<K1> |
getAllKeys1()
Returns list containing all keys in element order.
|
IList<K2> |
getAllKeys2()
Returns list containing all keys in element order.
|
protected Key2Collection.Builder<E,K1,K2> |
getBuilder() |
E |
getByKey1(K1 key)
Returns element with specified key.
|
E |
getByKey2(K2 key)
Returns element with specified key.
|
int |
getCountByKey1(K1 key)
Returns the number of elements with specified key.
|
int |
getCountByKey2(K2 key)
Returns the number of elements with specified key.
|
java.util.Set<K1> |
getDistinctKeys1()
Returns all distinct keys in the same order as in the key map.
|
java.util.Set<K2> |
getDistinctKeys2()
Returns all distinct keys in the same order as in the key map.
|
java.util.function.Function<E,K1> |
getKey1Mapper()
Returns mapper for key map.
|
java.util.function.Function<E,K2> |
getKey2Mapper()
Returns mapper for key map.
|
void |
invalidate(E elem)
Invalidate element, i.e. all keys of the element are extracted
again and stored in the key maps.
|
void |
invalidateKey1(K1 oldKey,
K1 newKey,
E elem)
Invalidate key value of element.
|
void |
invalidateKey2(K2 oldKey,
K2 newKey,
E elem)
Invalidate key value of element.
|
E |
put(E elem)
Adds or replaces element.
|
E |
putByKey1(E elem)
Adds element by key.
|
E |
putByKey2(E elem)
Adds element by key.
|
Key2Collection<E,K1,K2> |
removeAll(E elem)
Removes all equal elements.
|
Key2Collection<E,K1,K2> |
removeAllByKey1(K1 key)
Removes all elements with specified key.
|
Key2Collection<E,K1,K2> |
removeAllByKey2(K2 key)
Removes all elements with specified key.
|
E |
removeByKey1(K1 key)
Removes element with specified key.
|
E |
removeByKey2(K2 key)
Removes element with specified key.
|
add, addAll, asSet, clear, clone, contains, containsAll, containsKey, doAdd, doRemoveByKey, equals, filterMap, flatMap, getAllByKey, getAllByKey, getAllKeys, getByKey, getCount, getCountByKey, getDistinct, getDistinctKeys, getKeyMapper, hashCode, initClone, invalidateKey, isEmpty, isSorted, iterator, map, mapFilter, putByKey, remove, removeAll, removeAllByKey, removeAllByKey, removeByKey, retainAll, size, toArray, toArray, toList, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
containsIf, countIf, getFirst, getFirstOrNull, getIf, getSingle, getSingleOrNull
protected Key2Collection()
protected Key2Collection.Builder<E,K1,K2> getBuilder()
public Key2Collection<E,K1,K2> copy()
KeyCollectionImpl
copy
in interface ICollection<E>
copy
in class KeyCollectionImpl<E>
public Key2Collection<E,K1,K2> crop()
KeyCollectionImpl
crop
in interface ICollection<E>
crop
in class KeyCollectionImpl<E>
public Key2Collection<E,K1,K2> getAll(E elem)
KeyCollectionImpl
getAll
in class KeyCollectionImpl<E>
elem
- elementpublic Key2Collection<E,K1,K2> removeAll(E elem)
KeyCollectionImpl
removeAll
in class KeyCollectionImpl<E>
elem
- elementpublic E put(E elem)
KeyCollectionImpl
remove(elem); add(elem);However the method is atomic in the sense that all or none operations are executed. So if there is already such an element, but adding the new one fails due to a constraint violation, the old element remains in the list.
put
in class KeyCollectionImpl<E>
elem
- elementpublic void invalidate(E elem)
KeyCollectionImpl
invalidate
in class KeyCollectionImpl<E>
elem
- element to invalidatepublic java.util.function.Function<E,K1> getKey1Mapper()
public java.util.Map<K1,E> asMap1()
java.lang.IllegalArgumentException
- if the key map cannot be viewed as Mappublic boolean containsKey1(K1 key)
key
- keypublic E getByKey1(K1 key)
key
- keypublic Key2Collection<E,K1,K2> getAllByKey1(K1 key)
key
- keypublic int getCountByKey1(K1 key)
key
- keypublic E removeByKey1(K1 key)
key
- keypublic Key2Collection<E,K1,K2> removeAllByKey1(K1 key)
key
- keypublic IList<K1> getAllKeys1()
public java.util.Set<K1> getDistinctKeys1()
public E putByKey1(E elem)
removeByKey1(elem.getKey1()); add(elem);However the method is atomic in the sense that all or none operations are executed. So if there is already such an element, but adding the new one fails due to a constraint violation, the old element remains in the list.
elem
- elementpublic void invalidateKey1(K1 oldKey, K1 newKey, E elem)
oldKey
- old key valuenewKey
- new key valueelem
- element to invalidate (can be null if there are no duplicates with this key)public java.util.function.Function<E,K2> getKey2Mapper()
public java.util.Map<K2,E> asMap2()
java.lang.IllegalArgumentException
- if the key map cannot be viewed as Mappublic boolean containsKey2(K2 key)
key
- keypublic E getByKey2(K2 key)
key
- keypublic Key2Collection<E,K1,K2> getAllByKey2(K2 key)
key
- keypublic int getCountByKey2(K2 key)
key
- keypublic E removeByKey2(K2 key)
key
- keypublic Key2Collection<E,K1,K2> removeAllByKey2(K2 key)
key
- keypublic IList<K2> getAllKeys2()
public java.util.Set<K2> getDistinctKeys2()
public E putByKey2(E elem)
removeByKey2(elem.getKey2()); add(elem);However the method is atomic in the sense that all or none operations are executed. So if there is already such an element, but adding the new one fails due to a constraint violation, the old element remains in the list.
elem
- elementpublic void invalidateKey2(K2 oldKey, K2 newKey, E elem)
oldKey
- old key valuenewKey
- new key valueelem
- element to invalidate (can be null if there are no duplicates with this key)public Key2Collection<E,K1,K2> filter(java.util.function.Predicate<? super E> filter)
ICollection
filter
in interface ICollection<E>
filter
in class KeyCollectionImpl<E>
filter
- filter predicate