Package org.basex.util.list
Class ObjectList<E,L extends ObjectList<E,?>>
java.lang.Object
org.basex.util.list.ElementList
org.basex.util.list.ObjectList<E,L>
- Type Parameters:
E- generic object typeL- generic object type
- All Implemented Interfaces:
Iterable<E>
- Direct Known Subclasses:
AnnList,ANodeBuilder,ANodeList,ExprList,FTMatch,FTMatches,FTTokens,ItemList,RegExpList,StringList,TokenList,ValueList,VarStack
public abstract class ObjectList<E,L extends ObjectList<E,?>>
extends ElementList
implements Iterable<E>
This is an abstract class for storing objects of any kind in an array-based list.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsFields inherited from class org.basex.util.list.ElementList
factor, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an element to the array.final LAdds elements to the array.final LAdds elements from a string list to the array.Adds an element to the array if it is not contained yet.booleanChecks if the specified element is found in the list.booleanCompares two list elements.booleanfinal E[]finish()Returns an array with all elements and invalidates the internal array.get(int i) Returns the element at the specified index.final voidInserts the given elements at the specified position.iterator()protected abstract E[]newArray(int s) Creates a resized array.E[]next()Returns an array with all elements and resets the array size.peek()Returns the uppermost element on the stack, without removing it.final Epop()Pops the uppermost element from the stack.final voidPushes an element onto the stack.final Eremove(int index) Deletes the element at the specified position.booleanRemoves all occurrences of the specified element from the list.Removes all elements from the specified list.final LSets an element at the specified index position.final Lsort(Comparator<E> comp, boolean ascending) Sorts the elements.final E[]toArray()Returns an array with all elements.toString()final Lunique()Removes duplicates, provided that the entries are sorted.Methods inherited from class org.basex.util.list.ElementList
isEmpty, newCapacity, newCapacity, reset, size, sizeMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
list
Element container.
-
-
Constructor Details
-
ObjectList
Constructor.- Parameters:
list- initial list .
-
-
Method Details
-
newArray
Creates a resized array.- Parameters:
s- size- Returns:
- array
-
get
Returns the element at the specified index.- Parameters:
i- index- Returns:
- element, or
nullif index exceeds list size
-
contains
Checks if the specified element is found in the list.- Parameters:
element- element to be found- Returns:
- result of check
-
addUnique
Adds an element to the array if it is not contained yet.- Parameters:
element- element to be added- Returns:
- result of check
-
add
Adds an element to the array.- Parameters:
element- element to be added- Returns:
- self reference
-
add
Adds elements to the array.- Parameters:
elements- elements to be added- Returns:
- self reference
-
add
Adds elements from a string list to the array.- Parameters:
elements- string list to be added- Returns:
- self reference
-
set
Sets an element at the specified index position.- Parameters:
index- indexelement- element to be set- Returns:
- self reference
-
insert
Inserts the given elements at the specified position.- Parameters:
index- inserting positionelements- elements to insert
-
remove
Deletes the element at the specified position.- Parameters:
index- index of the element to delete- Returns:
- deleted element
-
removeAll
Removes all occurrences of the specified element from the list.- Parameters:
element- element to be removed- Returns:
- flag, indicating if any element was removed
-
removeAll
Removes all elements from the specified list.- Parameters:
elements- elements- Returns:
- self reference
-
pop
Pops the uppermost element from the stack.- Returns:
- the popped element
-
push
Pushes an element onto the stack.- Parameters:
element- element
-
peek
Returns the uppermost element on the stack, without removing it.- Returns:
- uppermost element
-
toArray
Returns an array with all elements.- Returns:
- array
-
finish
Returns an array with all elements and invalidates the internal array. Warning: the function must only be called if the list is discarded afterwards.- Returns:
- array (internal representation!)
-
next
Returns an array with all elements and resets the array size.- Returns:
- array
-
sort
Sorts the elements.- Parameters:
comp- comparatorascending- ascending/descending order- Returns:
- self reference
-
equals
Compares two list elements.- Parameters:
element1- first elementelement2- second element- Returns:
- result of check
-
unique
Removes duplicates, provided that the entries are sorted.- Returns:
- self reference
-
iterator
-
equals
-
toString
-