Package org.basex.query.util.list
Class ANodeBuilder
- java.lang.Object
-
- org.basex.util.list.ElementList
-
- org.basex.util.list.ObjectList<ANode,ANodeBuilder>
-
- org.basex.query.util.list.ANodeBuilder
-
public final class ANodeBuilder extends ObjectList<ANode,ANodeBuilder>
Resizable-array implementation for nodes. The stored nodes will be sorted and duplicates will be removed before they are returned as value or via an iterator.- Author:
- BaseX Team 2005-24, BSD License, Christian Gruen
-
-
Field Summary
-
Fields inherited from class org.basex.util.list.ObjectList
list
-
Fields inherited from class org.basex.util.list.ElementList
factor, size
-
-
Constructor Summary
Constructors Constructor Description ANodeBuilder()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ANodeBuilder
add(ANode node)
Adds an element to the array.int
binarySearch(DBNode node, int start, int length)
Performs a binary search on the given range of this sequence iterator.boolean
contains(ANode node)
Checks if the specified element is found in the list.Data
data()
Returns the shared database.void
ddo()
Sorts the nodes and removes distinct nodes.boolean
equals(Object obj)
boolean
equals(ANode node1, ANode node2)
Compares two list elements.ANode[]
finish()
Returns an array with all elements and invalidates the internal array.Iterator<ANode>
iterator()
protected ANode[]
newArray(int s)
Creates a resized array.boolean
removeAll(ANode node)
Removes all occurrences of the specified element from the list.Value
value(Expr expr)
Returns a value with the type of the given expression and invalidates the internal array.-
Methods inherited from class org.basex.util.list.ObjectList
add, add, addUnique, get, insert, next, peek, pop, push, remove, removeAll, reverse, set, sort, toArray, toString, unique
-
Methods inherited from class org.basex.util.list.ElementList
isEmpty, newCapacity, newCapacity, reset, size, size
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
add
public ANodeBuilder add(ANode node)
Description copied from class:ObjectList
Adds an element to the array.- Overrides:
add
in classObjectList<ANode,ANodeBuilder>
- Parameters:
node
- element to be added- Returns:
- self reference
-
value
public Value value(Expr expr)
Returns a value with the type of the given expression and invalidates the internal array. Warning: the function must only be called if the builder is discarded afterwards.- Parameters:
expr
- expression- Returns:
- the iterator
-
ddo
public void ddo()
Sorts the nodes and removes distinct nodes.
-
data
public Data data()
Returns the shared database.- Returns:
- database or
null
-
removeAll
public boolean removeAll(ANode node)
Description copied from class:ObjectList
Removes all occurrences of the specified element from the list.- Overrides:
removeAll
in classObjectList<ANode,ANodeBuilder>
- Parameters:
node
- element to be removed- Returns:
- flag, indicating if any element was removed
-
contains
public boolean contains(ANode node)
Description copied from class:ObjectList
Checks if the specified element is found in the list.- Overrides:
contains
in classObjectList<ANode,ANodeBuilder>
- Parameters:
node
- element to be found- Returns:
- result of check
-
finish
public ANode[] finish()
Description copied from class:ObjectList
Returns an array with all elements and invalidates the internal array. Warning: the function must only be called if the list is discarded afterwards.- Overrides:
finish
in classObjectList<ANode,ANodeBuilder>
- Returns:
- array (internal representation!)
-
binarySearch
public int binarySearch(DBNode node, int start, int length)
Performs a binary search on the given range of this sequence iterator. This works ifdata
is assigned.- Parameters:
node
- node to findstart
- start of the search intervallength
- length of the search interval- Returns:
- position of the item or
-insertPosition - 1
if not found
-
iterator
public Iterator<ANode> iterator()
- Specified by:
iterator
in interfaceIterable<ANode>
- Overrides:
iterator
in classObjectList<ANode,ANodeBuilder>
-
newArray
protected ANode[] newArray(int s)
Description copied from class:ObjectList
Creates a resized array.- Specified by:
newArray
in classObjectList<ANode,ANodeBuilder>
- Parameters:
s
- size- Returns:
- array
-
equals
public boolean equals(ANode node1, ANode node2)
Description copied from class:ObjectList
Compares two list elements.- Overrides:
equals
in classObjectList<ANode,ANodeBuilder>
- Parameters:
node1
- first elementnode2
- second element- Returns:
- result of check
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObjectList<ANode,ANodeBuilder>
-
-