Class KeyList.ImmutableKeyList<E>
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.KeyList<E>
org.magicwerk.brownies.collections.KeyList.ImmutableKeyList<E>
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>, ICollection<E>, IListable<E>
-
Nested Class Summary
Nested classes/interfaces inherited from class KeyList
KeyList.Builder<E>, KeyList.ImmutableKeyList<E>Nested classes/interfaces inherited from class IList
IList.IListableFromArray<E>, IList.IListableFromCollection<E>, IList.IListableFromList<E>, IList.IListableFromMult<E>, IList.Iter, IList.ListIter -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longUID for serializationFields inherited from class KeyListImpl
keyColl, listFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedImmutableKeyList(KeyList<E> that) Private constructor used internally. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanHelper method for adding an element to the list.protected voiddoClear()protected voiddoEnsureCapacity(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 voiddoModify()This method is called internally before elements are allocated or freed.protected EdoRemove(int index) Helper method to remove an element.protected voiddoRemoveAll(int index, int len) Remove specified range of elements from list.protected ESets an element at specified position.protected EHelper method for setting an element in the list.private voiderror()Throw exception if an attempt is made to change an immutable list.protected voidinvalidateKey(int keyIndex, Object oldKey, Object newKey, E elem) Invalidate key value of element.protected EPut element by key into list.removeAllByKey(int keyIndex, Object key) Removes element by key.protected EremoveByKey(int keyIndex, Object key) Removes element by key.Methods inherited from class KeyList
clone, copy, count, crop, getAll, getBuilder, getDistinct, immutableList, isReadOnly, put, removeAll, unmodifiableListMethods inherited from class 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, unwrapMethods inherited from class 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, transformedListMethods inherited from class AbstractList
removeRange, subListMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
replaceAll, reversed, spliterator, subList
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUID for serialization- See Also:
-
-
Constructor Details
-
ImmutableKeyList
-
-
Method Details
-
doEnsureCapacity
protected void doEnsureCapacity(int capacity) Description copied from class:IListIncreases 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:
doEnsureCapacityin classKeyListImpl<E>- Parameters:
capacity- the desired minimum capacity
-
doAdd
Description copied from class:IListHelper 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:
doAddin 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:IListHelper 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:
doSetin 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:IListSets 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:
doReSetin 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:IListHelper 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:
doRemovein classKeyListImpl<E>- Parameters:
index- index of element to remove- Returns:
- removed element
-
doRemoveAll
protected void doRemoveAll(int index, int len) Description copied from class:IListRemove specified range of elements from list.- Overrides:
doRemoveAllin classKeyListImpl<E>- Parameters:
index- index of first element to removelen- number of elements to remove
-
doClear
-
doModify
-
removeByKey
Description copied from class:KeyListImplRemoves element by key. If there are duplicates, only one element is removed.- Overrides:
removeByKeyin 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:KeyListImplRemoves element by key. If there are duplicates, all elements are removed.- Overrides:
removeAllByKeyin 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:KeyListImplPut element by key into list.- Overrides:
putByKeyin 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:KeyListImplInvalidate 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:
invalidateKeyin 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.
-