Class CharObjBigList
java.lang.Object
java.util.AbstractCollection<Character>
java.util.AbstractList<Character>
org.magicwerk.brownies.collections.IList<Character>
org.magicwerk.brownies.collections.primitive.CharObjBigList
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Character>,Collection<Character>,List<Character>,RandomAccess,SequencedCollection<Character>,ICollection<Character>,IListable<Character>
- Direct Known Subclasses:
CharObjBigList.ImmutableCharObjBigList
CharObjBigList implements the List interface and uses an instance
of CharBigList for storage. It therefore allows to use the advantages
of primitive collections like saved memory and improved execution
speed when standard list collections are expected.
Note that this implementation is not synchronized.
- Version:
- $Id: CharObjBigList.java 2200 2014-03-21 10:46:29Z origo $
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAn immutable version of a BigList.Nested classes/interfaces inherited from class org.magicwerk.brownies.collections.IList
IList.IListableFromArray<E>, IList.IListableFromCollection<E>, IList.IListableFromList<E>, IList.IListableFromMult<E> -
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionCharObjBigList(int capacity) CharObjBigList(Collection<? extends Character> elems) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAll(int index, Collection<? extends Character> coll) Inserts all of the elements in the specified collection into this list, starting at the specified position.booleanInserts all of the elements in the specified list into this list, starting at the specified position.booleanaddAll(Collection<? extends Character> coll) Adds all of the elements in the specified collection into this list.booleanAdds all of the elements in the specified list into this list.booleanInserts the specified elements into this list, starting at the specified position.booleanAdds all specified elements into this list.<K> intbinarySearch(int index, int len, K key, Comparator<? super K> comparator) Searches the specified range for an object using the binary search algorithm.intcapacity()Returns capacity of this BigList.clone()Returns a shallow copy of this list.booleanbooleancontainsAll(Collection<?> coll) booleancontainsAny(Collection<?> coll) Returns true if any of the elements of the specified collection is contained in the list.copy()Returns a shallow copy of this list.static CharObjBigListcreate()static CharObjBigListstatic CharObjBigListcreate(Collection<? extends Character> elems) protected booleanHelper method for adding an element to the list.protected voidAssign this list the content of the that list.protected voidInitialize this object after the bitwise copy has been made by Object.clone().doCreate(int capacity) Create list with specified capacity.protected voiddoEnsureCapacity(int minCapacity) 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 CharacterdoGet(int index) Helper method for getting an element from the list.protected voidHelper method to fill the specified elements in an array.protected CharacterdoRemove(int index) Helper method to remove an element.protected voiddoRemoveAll(int index, int len) Remove specified range of elements from list.protected CharacterSets an element at specified position.protected CharacterHelper method for setting an element in the list.booleanget(int index) Return element at specified positiongetAll(int index, int len) Returns specified range of elements from list.inthashCode()Returns an immutable copy of this list.intvoidinit()voidvoidinit(Collection<? extends Character> elems) booleanisEmpty()booleanReturns true if this list is either unmodifiable or immutable, false otherwise.intlastIndexOf(Object elem) voidmove(int srcIndex, int dstIndex, int len) Move specified elements.booleanbooleanremoveAll(Collection<?> coll) booleanbooleanremoveFirstOccurrence(Object elem) booleanremoveLastOccurrence(Object elem) booleanretainAll(Collection<?> coll) booleanvoidsetAll(int index, Collection<? extends Character> coll) Sets the specified elements.voidSets the specified elements.voidSets the specified elements.intsize()Return size of listvoidsort(int index, int len, Comparator comparator) Sort specified elements in the list using the specified comparator.Object[]toArray(int index, int len) Returns an array containing the specified elements in this list.<T> T[]Returns an array containing the specified elements in this list.<T> T[]toArray(T[] array, int index, int len) Returns an array containing the specified elements in this list.(package private) static char[]toPrimitive(Character[] elems) (package private) static char[]toPrimitive(Collection<? extends Character> list) (package private) static char[]toPrimitive(BigList<? extends Character> list2) toString()(package private) static Character[]toWrapper(char[] elems) voidAn application can use this operation to minimize the storage of an instance.Returns an unmodifiable view of this list.Methods inherited from class org.magicwerk.brownies.collections.IList
add, add, addArray, addArray, addFirst, addIfAbsent, addLast, addMult, addMult, asDeque, asIListable, binarySearch, checkIndex, checkIndexAdd, checkLength, checkLengths, checkNonNull, checkRange, clear, containsIf, copy, count, countIf, crop, descendingIterator, doAddAll, doClear, doCreateArray, doIndexOf, doIndexOfIf, doInitAll, doLastIndexOf, doLastIndexOfIf, doModify, doPutAll, doReplace, doRotate, drag, element, ensureCapacity, extract, extractIf, fill, filter, filterMap, flatMap, getAll, getDistinct, getFirst, getFirstOrNull, getIf, getLast, getLastOrNull, getSingle, getSingleOrNull, indexOf, indexOfIf, indexOfIf, initAll, initAll, initArray, initMult, iterator, lastIndexOf, lastIndexOfIf, lastIndexOfIf, listIterator, listIterator, map, mapFilter, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, put, putAll, putAll, putArray, putMult, remove, remove, remove, removeAll, removeFirst, removeIf, removeLast, replace, replaceAll, replaceAll, replaceArray, replaceMult, resize, retain, retainIf, reverse, reverse, rotate, rotate, set, setArray, setMult, sort, swap, toArray, toArray, toArray, transferCopy, transferMove, transferRemove, transferSwap, transform, transformedListMethods inherited from class java.util.AbstractList
removeRange, subListMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
replaceAll, reversed, spliterator, subList
-
Field Details
-
list
CharBigList list
-
-
Constructor Details
-
CharObjBigList
public CharObjBigList() -
CharObjBigList
public CharObjBigList(int capacity) -
CharObjBigList
-
-
Method Details
-
toWrapper
-
toPrimitive
-
toPrimitive
-
toPrimitive
-
create
-
create
-
create
-
init
public void init() -
init
-
init
-
doClone
Description copied from class:IListInitialize this object after the bitwise copy has been made by Object.clone(). -
doAssign
Description copied from class:IListAssign this list the content of the that list. This is done by bitwise copying so the that list should not be used afterwards. -
isReadOnly
public boolean isReadOnly()Description copied from class:IListReturns true if this list is either unmodifiable or immutable, false otherwise.- Specified by:
isReadOnlyin classIList<Character>
-
copy
Description copied from class:IListReturns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. This returned list will be modifiable, i.e. a read-only list will be copied and be modifiable again. -
clone
Description copied from class:IListReturns a shallow copy of this list. The new list will contain the same elements as the source list, i.e. the elements themselves are not copied. The capacity of the list will be set to the number of elements, i.e. size and capacity are equal. If the list is read-only, the same list is returned without change. UseIList.copy()to . -
getDefaultElem
- Specified by:
getDefaultElemin classIList<Character>
-
doCreate
Description copied from class:IListCreate list with specified capacity. -
size
public int size()Description copied from interface:IListableReturn size of list -
capacity
public int capacity()Returns capacity of this BigList. Note that two BigLists are considered equal even if they have a distinct capacity. Also the capacity can be changed by operations like clone() etc. -
get
Description copied from interface:IListableReturn element at specified position -
doGet
Description copied from class:IListHelper method for getting an element from the list. This is the only method which really gets an element. Override if you need to validity checks before getting. -
doGetAll
Description copied from class:IListHelper method to fill the specified elements in an array. -
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. -
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. -
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. -
doRemoveAll
protected void doRemoveAll(int index, int len) Description copied from class:IListRemove specified range of elements from list.- Overrides:
doRemoveAllin classIList<Character>- Parameters:
index- index of first element to removelen- number of elements to remove
-
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. -
move
public void move(int srcIndex, int dstIndex, int len) Description copied from class:IListMove specified elements. Source and destination ranges may overlap. The elements which are moved away are set to null, so the size of the list does not change. -
doEnsureCapacity
protected void doEnsureCapacity(int minCapacity) 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.- Specified by:
doEnsureCapacityin classIList<Character>- Parameters:
minCapacity- the desired minimum capacity
-
trimToSize
public void trimToSize()Description copied from class:IListAn application can use this operation to minimize the storage of an instance.- Specified by:
trimToSizein classIList<Character>
-
equals
-
hashCode
public int hashCode() -
toString
-
isEmpty
public boolean isEmpty() -
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<Character>- Overrides:
lastIndexOfin classIList<Character>
-
remove
-
contains
-
containsAny
Description copied from class:IListReturns true if any of the elements of the specified collection is contained in the list.- Overrides:
containsAnyin classIList<Character>- Parameters:
coll- collection with elements to be contained- Returns:
- true if any element is contained, false otherwise
-
containsAll
- Specified by:
containsAllin interfaceCollection<Character>- Specified by:
containsAllin interfaceList<Character>- Overrides:
containsAllin classIList<Character>
-
removeAll
-
removeAll
-
retainAll
-
retainAll
-
toArray
Returns an array containing the specified elements in this list. -
toArray
public <T> T[] toArray(T[] array, int index, int len) Returns an array containing the specified elements in this list.- Overrides:
toArrayin classIList<Character>- Parameters:
array- the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purposeindex- index of first element to copylen- number of elements to copy- Returns:
- array containing the specified elements
- See Also:
-
toArray
Returns an array containing the specified elements in this list. -
addAll
Description copied from class:IListAdds all of the elements in the specified collection into this list. The new elements will appear in the list in the order that they are returned by the specified collection's iterator. -
addAll
Description copied from class:IListInserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.- Specified by:
addAllin interfaceList<Character>- Overrides:
addAllin classIList<Character>- Parameters:
index- index at which to insert the first element from the specified collectioncoll- collection containing elements to be inserted into this list- Returns:
- true if this list changed as a result of the call
-
addArray
Description copied from class:IListAdds all specified elements into this list. -
addArray
Description copied from class:IListInserts the specified elements into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). -
addAll
Description copied from class:IListAdds all of the elements in the specified list into this list. -
addAll
Description copied from class:IListInserts all of the elements in the specified list into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). -
removeFirstOccurrence
Description copied from class:IList- Overrides:
removeFirstOccurrencein classIList<Character>
-
removeLastOccurrence
Description copied from class:IList- Overrides:
removeLastOccurrencein classIList<Character>
-
getAll
Description copied from class:IListReturns specified range of elements from list. -
setAll
Description copied from class:IListSets the specified elements. -
setAll
Description copied from class:IListSets the specified elements. -
setArray
Description copied from class:IListSets the specified elements. -
sort
Description copied from class:IListSort specified elements in the list using the specified comparator. -
binarySearch
Description copied from class:IListSearches the specified range for an object using the binary search algorithm.Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:
persons.binarySearch("john", new SearchByName()); class SearchByName implements Comparator<Object> { public int compare(Object o1, Object o2) { String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName(); String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName(); return s1.compareTo(s2); } }/- Specified by:
binarySearchin classIList<Character>- Parameters:
index- index of first element to searchlen- number of elements to searchkey- the value to be searched forcomparator- the comparator by which the list is ordered. A null value indicates that the elements' natural ordering should be used.- Returns:
- index of the search key, if it is contained in the array; otherwise, (-(insertion point) - 1). The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element greater than the key, or a.length if all elements in the array are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.
- See Also:
-
unmodifiableList
Description copied from class:IListReturns an unmodifiable view of this list. This method allows modules to provide users with "read-only" access to internal lists, where changes made to the original list are visible as query operations on the returned list "read through" to the specified list. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already unmodifiable, it is returned unchanged. SeeIList.immutableList()to get an immutable copy of a list.- Specified by:
unmodifiableListin classIList<Character>- Returns:
- an unmodifiable view of the specified list
-
immutableList
Description copied from class:IListReturns an immutable copy of this list. The returned list is independent from the original list, i.e. changes done later are not seen. Attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException. If this list is already immutable, it is returned unchanged. SeeIList.unmodifiableList()to get unmodifiable view of a list.- Specified by:
immutableListin classIList<Character>- Returns:
- an immutable copy of the specified list
-