Class Key1List.ReadOnlyKey1List<E,K>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.magicwerk.brownies.collections.IList<E>
org.magicwerk.brownies.collections.KeyListImpl<E>
org.magicwerk.brownies.collections.Key1List<E,K>
org.magicwerk.brownies.collections.Key1List.ReadOnlyKey1List<E,K>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,SequencedCollection<E>
,ICollection<E>
,IListable<E>
A read-only version of
Key1List
.
It is used to implement both unmodifiable and immutable lists.
Note that the client cannot change the list, but the content may change if the underlying list is changed.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.magicwerk.brownies.collections.Key1List
Key1List.Builder<E,
K>, Key1List.ReadOnlyKey1List<E, K> Nested classes/interfaces inherited from class org.magicwerk.brownies.collections.IList
IList.IListableFromArray<E>, IList.IListableFromCollection<E>, IList.IListableFromList<E>, IList.IListableFromMult<E>, IList.Iter, IList.ListIter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
UID for serializationFields inherited from class org.magicwerk.brownies.collections.KeyListImpl
keyColl, list
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ReadOnlyKey1List
(Key1List<E, K> that) Private constructor used internally. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Helper method for adding an element to the list.protected void
doClear()
protected void
doEnsureCapacity
(int capacity) Increases the capacity of this list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.protected void
doModify()
This method is called internally before elements are allocated or freed.protected E
doRemove
(int index) Helper method to remove an element.protected void
doRemoveAll
(int index, int len) Remove specified range of elements from list.protected E
Sets an element at specified position.protected E
Helper method for setting an element in the list.private void
error()
Throw exception if an attempt is made to change an immutable list.protected void
invalidateKey
(int keyIndex, Object oldKey, Object newKey, E elem) Invalidate key value of element.protected E
Put element by key into list.removeAllByKey
(int keyIndex, Object key) Removes element by key.protected E
removeByKey
(int keyIndex, Object key) Removes element by key.Methods inherited from class org.magicwerk.brownies.collections.Key1List
asMap1, clone, containsKey1, copy, count, crop, getAll, getAllByKey1, getAllKeys1, getBuilder, getByKey1, getCountByKey1, getDistinct, getDistinctKeys1, getKey1Mapper, immutableList, indexOfKey1, invalidateKey1, isReadOnly, put, putByKey1, putIfAbsentByKey1, removeAll, removeAllByKey1, removeByKey1, unmodifiableList
Methods inherited from class org.magicwerk.brownies.collections.KeyListImpl
add, add, asSet, binarySearch, capacity, clear, contains, containsKey, doAssign, doClone, doCreate, doGet, doGetAll, ensureCapacity, get, getAllByKey, getAllKeys, getByKey, getCountByKey, getDefaultElem, getDistinctKeys, getKeyMapper, indexOf, indexOfKey, indexOfKey, initCopy, initCrop, invalidate, isContainsFast, isIndexOfFast, isSorted, remove, set, size, sort, trimToSize, unwrap
Methods inherited from class org.magicwerk.brownies.collections.IList
addAll, addAll, addAll, addAll, addArray, addArray, addArray, addArray, addFirst, addIfAbsent, addLast, addMult, addMult, asDeque, asIListable, binarySearch, checkIndex, checkIndexAdd, checkLength, checkLengths, checkNonNull, checkRange, containsAll, containsAny, containsIf, copy, countIf, descendingIterator, doAddAll, doCreateArray, doIndexOf, doIndexOfIf, doInitAll, doLastIndexOf, doLastIndexOfIf, doPutAll, doReplace, doRotate, doTransfer, doTransferSwap, drag, element, equals, equalsElem, extract, extractIf, fill, filter, filterMap, flatMap, getAll, getFirst, getFirstOrNull, getIf, getLast, getLastOrNull, getSingle, getSingleOrNull, hashCode, hashCodeElem, indexOf, indexOfIf, indexOfIf, initAll, initAll, initArray, initMult, isEmpty, iterator, lastIndexOf, lastIndexOf, lastIndexOfIf, lastIndexOfIf, listIterator, listIterator, map, mapFilter, move, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, put, putAll, putAll, putArray, putMult, remove, remove, remove, removeAll, removeAll, removeFirst, removeFirstOccurrence, removeIf, removeLast, removeLastOccurrence, replace, replaceAll, replaceAll, replaceArray, replaceMult, resize, retain, retainAll, retainAll, retainIf, reverse, reverse, rotate, rotate, setAll, setAll, setArray, setArray, setMult, sort, swap, toArray, toArray, toArray, toArray, toArray, toArray, toArray, toString, transferCopy, transferMove, transferRemove, transferSwap, transform, transformedList
Methods inherited from class java.util.AbstractList
removeRange, subList
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
replaceAll, reversed, spliterator, subList
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUID for serialization- See Also:
-
-
Constructor Details
-
ReadOnlyKey1List
Private constructor used internally.- Parameters:
that
- list to create an immutable view of
-
-
Method Details
-
doEnsureCapacity
protected void doEnsureCapacity(int capacity) Description copied from class:IList
Increases the capacity of this list instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.- Overrides:
doEnsureCapacity
in classKeyListImpl<E>
- Parameters:
capacity
- the desired minimum capacity
-
doAdd
Description copied from class:IList
Helper method for adding an element to the list. This is the only method which really adds an element. Override if you need to validity checks before adding.- Overrides:
doAdd
in classKeyListImpl<E>
- Parameters:
index
- index where element should be added (-1 means it is up to the implementation to choose the index)elem
- element to add- Returns:
- true if element has been added, false otherwise
-
doSet
Description copied from class:IList
Helper method for setting an element in the list. This is the only method which really sets an element. Override if you need to validity checks before setting.- Overrides:
doSet
in classKeyListImpl<E>
- Parameters:
index
- index where element will be placedelem
- element to set- Returns:
- old element which was at the position
-
doReSet
Description copied from class:IList
Sets an element at specified position. This method is used internally if existing elements will be moved etc. Override if you need to validity checks.- Overrides:
doReSet
in classKeyListImpl<E>
- Parameters:
index
- index where element will be placedelem
- element to set- Returns:
- old element which was at the position
-
doRemove
Description copied from class:IList
Helper method to remove an element. This is the only method which really removes an element. Override if you need to validity checks before removing.- Overrides:
doRemove
in classKeyListImpl<E>
- Parameters:
index
- index of element to remove- Returns:
- removed element
-
doRemoveAll
protected void doRemoveAll(int index, int len) Description copied from class:IList
Remove specified range of elements from list.- Overrides:
doRemoveAll
in classKeyListImpl<E>
- Parameters:
index
- index of first element to removelen
- number of elements to remove
-
doClear
protected void doClear() -
doModify
protected void doModify()Description copied from class:IList
This method is called internally before elements are allocated or freed. Override if you need to validity checks. -
removeByKey
Description copied from class:KeyListImpl
Removes element by key. If there are duplicates, only one element is removed.- Overrides:
removeByKey
in classKeyListImpl<E>
- Parameters:
keyIndex
- key indexkey
- key of element to remove- Returns:
- removed element or null if no element has been removed
-
removeAllByKey
Description copied from class:KeyListImpl
Removes element by key. If there are duplicates, all elements are removed.- Overrides:
removeAllByKey
in classKeyListImpl<E>
- Parameters:
keyIndex
- key indexkey
- key of element to remove- Returns:
- true if elements have been removed, false otherwise
-
putByKey
Description copied from class:KeyListImpl
Put element by key into list.- Overrides:
putByKey
in classKeyListImpl<E>
- Parameters:
keyIndex
- key indexelem
- element to putreplace
- true to replace an existing element with the same key, false to let the element unchanged- Returns:
- element with the same key (i.e. element which was replaced if replace is true / which was left unchanged if false), null if no element with the same key has been found
-
invalidateKey
Description copied from class:KeyListImpl
Invalidate key value of element. You must call an invalidate method if an element's key value has changed after adding it to the collection.- Overrides:
invalidateKey
in classKeyListImpl<E>
- Parameters:
keyIndex
- key indexoldKey
- old key valuenewKey
- new key valueelem
- element to invalidate (can be null if there are no duplicates with this key)
-
error
private void error()Throw exception if an attempt is made to change an immutable list.
-