E
- type of elements stored in the listpublic class KeyCollectionImpl<E> extends java.lang.Object implements ICollection<E>, java.io.Serializable, java.lang.Cloneable
GapList
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
KeyCollectionImpl.BuilderImpl<E>
Implementation of builder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E elem) |
boolean |
addAll(java.util.Collection<? extends E> c) |
java.util.Set<E> |
asSet()
Returns a Set view of the element set.
|
void |
clear() |
protected java.lang.Object |
clone() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
protected <K> boolean |
containsKey(int keyIndex,
K key)
Checks whether the specified key exists in this list.
|
KeyCollectionImpl |
copy()
Returns a copy of this collection with all its elements.
|
KeyCollectionImpl |
crop()
Returns a copy of this collection but without elements.
|
protected boolean |
doAdd(E elem)
Helper method for adding an element to the collection.
|
protected Option<E> |
doRemoveByKey(int keyIndex,
java.lang.Object key)
Removes element by key.
|
boolean |
equals(java.lang.Object o) |
KeyCollectionImpl |
filter(java.util.function.Predicate<? super E> predicate)
Create a new collection by applying the specified filter to all elements.
|
<R> IList<R> |
filterMap(java.util.function.Predicate<E> filter,
java.util.function.Function<E,R> func)
Create a new list by applying the specified filter first and then the mapping function to all elements selected.
|
<R,C extends java.util.Collection<R>> |
flatMap(java.util.function.Function<E,C> func)
Create a new list by applying the specified mapping function to all elements.
|
java.util.Collection<E> |
getAll(E elem)
Returns all equal elements.
|
protected java.util.Collection<E> |
getAllByKey(int keyIndex,
java.lang.Object key)
Returns a collection with all elements with the specified key.
|
protected void |
getAllByKey(int keyIndex,
java.lang.Object key,
java.util.Collection<E> coll)
Fill the collection with all elements with the specified key.
|
protected IList<?> |
getAllKeys(int keyIndex)
Returns list containing all keys in element order.
|
protected E |
getByKey(int keyIndex,
java.lang.Object key)
Returns value for specified key.
|
int |
getCount(E elem)
Returns the number of equal elements.
|
protected int |
getCountByKey(int keyIndex,
java.lang.Object key)
Returns number of elements with specified key.
|
java.util.Set<E> |
getDistinct()
Returns all distinct elements in the same order as in the collection.
|
protected java.util.Set<?> |
getDistinctKeys(int keyIndex)
Returns set containing all distinct keys.
|
protected java.util.function.Function<E,java.lang.Object> |
getKeyMapper(int keyIndex)
Returns mapper for specified key map.
|
int |
hashCode() |
protected void |
initClone(java.lang.Object that)
Initialize this object after the bitwise copy has been made
by Object.clone().
|
protected void |
invalidate(E elem)
Invalidate element, i.e. all keys of the element are extracted
again and stored in the key maps.
|
protected void |
invalidateKey(int keyIndex,
java.lang.Object oldKey,
java.lang.Object newKey,
E elem)
Invalidate key value of element.
|
boolean |
isEmpty() |
boolean |
isSorted()
Determines whether this list is sorted or not.
|
java.util.Iterator<E> |
iterator() |
<R> IList<R> |
map(java.util.function.Function<E,R> func)
Create a new list by applying the specified mapping function to all elements.
|
<R> IList<R> |
mapFilter(java.util.function.Function<E,R> func,
java.util.function.Predicate<R> filter)
Create a new list by applying the specified mapping function to all elements and then filtering it.
|
protected E |
put(E elem)
Adds or replaces element.
|
protected E |
putByKey(int keyIndex,
E elem,
boolean replace) |
boolean |
remove(java.lang.Object elem) |
boolean |
removeAll(java.util.Collection<?> c) |
java.util.Collection<E> |
removeAll(E elem)
Removes all equal elements.
|
protected java.util.Collection<E> |
removeAllByKey(int keyIndex,
java.lang.Object key)
Removes element by key.
|
protected void |
removeAllByKey(int keyIndex,
java.lang.Object key,
java.util.Collection<E> removeds) |
protected E |
removeByKey(int keyIndex,
java.lang.Object key) |
boolean |
retainAll(java.util.Collection<?> c) |
int |
size() |
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
GapList<E> |
toList()
Returns all elements contained in this collection as list.
|
java.lang.String |
toString() |
finalize, getClass, notify, notifyAll, wait, wait, wait
containsIf, countIf, getFirst, getFirstOrNull, getIf, getSingle, getSingleOrNull
public boolean isSorted()
protected boolean doAdd(E elem)
public boolean remove(java.lang.Object elem)
remove
in interface java.util.Collection<E>
protected E put(E elem)
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.
elem
- elementpublic int size()
size
in interface java.util.Collection<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
public java.util.Iterator<E> iterator()
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
public GapList<E> toList()
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
public java.lang.String toString()
toString
in class java.lang.Object
public KeyCollectionImpl copy()
copy
in interface ICollection<E>
public KeyCollectionImpl crop()
crop
in interface ICollection<E>
protected java.lang.Object clone()
clone
in class java.lang.Object
protected void initClone(java.lang.Object that)
that
- source objectpublic java.util.Set<E> asSet()
java.lang.IllegalArgumentException
- if the element set cannot be viewed as Setpublic void clear()
clear
in interface java.util.Collection<E>
protected <K> boolean containsKey(int keyIndex, K key)
keyIndex
- key indexkey
- key to look forprotected java.util.Set<?> getDistinctKeys(int keyIndex)
keyIndex
- key indexprotected IList<?> getAllKeys(int keyIndex)
keyIndex
- key indexprotected java.util.function.Function<E,java.lang.Object> getKeyMapper(int keyIndex)
keyIndex
- key indexprotected E getByKey(int keyIndex, java.lang.Object key)
keyIndex
- key indexkey
- key to findprotected java.util.Collection<E> getAllByKey(int keyIndex, java.lang.Object key)
keyIndex
- key indexkey
- key which elements must haveprotected void getAllByKey(int keyIndex, java.lang.Object key, java.util.Collection<E> coll)
keyIndex
- key indexkey
- key which elements must havecoll
- collection with all elementsprotected int getCountByKey(int keyIndex, java.lang.Object key)
keyIndex
- key indexkey
- key which elements must haveprotected void invalidate(E elem)
elem
- element to invalidateprotected void invalidateKey(int keyIndex, java.lang.Object oldKey, java.lang.Object newKey, E elem)
keyIndex
- key indexoldKey
- old key valuenewKey
- new key valueelem
- element to invalidate (can be null if there are no duplicates with this key)protected E removeByKey(int keyIndex, java.lang.Object key)
protected Option<E> doRemoveByKey(int keyIndex, java.lang.Object key)
keyIndex
- index of key mapkey
- key of element to removeprotected java.util.Collection<E> removeAllByKey(int keyIndex, java.lang.Object key)
keyIndex
- key indexkey
- key of element to removeprotected void removeAllByKey(int keyIndex, java.lang.Object key, java.util.Collection<E> removeds)
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in class java.lang.Object
public java.util.Collection<E> getAll(E elem)
elem
- elementpublic int getCount(E elem)
elem
- elementpublic java.util.Collection<E> removeAll(E elem)
elem
- elementpublic java.util.Set<E> getDistinct()
public KeyCollectionImpl filter(java.util.function.Predicate<? super E> predicate)
ICollection
filter
in interface ICollection<E>
predicate
- filter predicatepublic <R> IList<R> map(java.util.function.Function<E,R> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.map
in interface ICollection<E>
func
- mapping functionpublic <R,C extends java.util.Collection<R>> IList<R> flatMap(java.util.function.Function<E,C> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.flatMap
in interface ICollection<E>
func
- mapping functionpublic <R> IList<R> mapFilter(java.util.function.Function<E,R> func, java.util.function.Predicate<R> filter)
ICollection
IList
, typically GapList
unless the original type is BigList
.mapFilter
in interface ICollection<E>
func
- mapping functionfilter
- filter predicatepublic <R> IList<R> filterMap(java.util.function.Predicate<E> filter, java.util.function.Function<E,R> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.filterMap
in interface ICollection<E>
filter
- filter predicatefunc
- mapping function