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:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,java.util.RandomAccess
,ICollection<E>
,IListable<E>
protected static class Key1List.ReadOnlyKey1List<E,K> extends Key1List<E,K>
A read-only version ofKey1List
. 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:
- Serialized Form
-
-
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
Fields Modifier and Type Field Description private static long
serialVersionUID
UID for serialization-
Fields inherited from class org.magicwerk.brownies.collections.KeyListImpl
keyColl, list
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReadOnlyKey1List(Key1List<E,K> that)
Private constructor used internally.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
doAdd(int index, E elem)
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
doReSet(int index, E elem)
Sets an element at specified position.protected E
doSet(int index, E elem)
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, java.lang.Object oldKey, java.lang.Object newKey, E elem)
Invalidate key value of element.protected E
putByKey(int keyIndex, E elem, boolean replace)
Put element by key into list.protected IList<E>
removeAllByKey(int keyIndex, java.lang.Object key)
Removes element by key.protected E
removeByKey(int keyIndex, java.lang.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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
UID for serialization- See Also:
- Constant Field Values
-
-
Method Detail
-
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
protected boolean doAdd(int index, E elem)
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
protected E doSet(int index, E elem)
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
protected E doReSet(int index, E elem)
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
protected E doRemove(int index)
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
-
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
protected E removeByKey(int keyIndex, java.lang.Object key)
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
protected IList<E> removeAllByKey(int keyIndex, java.lang.Object key)
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
protected E putByKey(int keyIndex, E elem, boolean replace)
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
protected void invalidateKey(int keyIndex, java.lang.Object oldKey, java.lang.Object newKey, E elem)
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.
-
-