Package org.basex.query.util.fingertree
Interface Node<N,E>
- Type Parameters:
N- node typeE- element type
- All Superinterfaces:
NodeLike<N,E>
A node inside a digit.
- Author:
- BaseX Team 2005-21, BSD License, Leo Woerteler
-
Method Summary
Modifier and TypeMethodDescriptionintarity()Number of children of this node.longChecks that this node does not violate any invariants.getSub(int pos) Returns the sub-node at the given position in this node.booleanInserts the given element at the given position in this node.Removes the element at the given position in this node.reverse()Creates a reversed version of this node.Replaces the element at the given position in this node with the given element.longsize()Number of elements in this node.slice(long off, long len) Extracts a sub-tree containing the elements at positionsoff .. off + len - 1from the tree rooted at this node.
-
Method Details
-
size
long size()Number of elements in this node.- Returns:
- number of elements
-
arity
int arity()Number of children of this node.- Returns:
- number of children
-
getSub
Returns the sub-node at the given position in this node.- Parameters:
pos- index of the sub-node, must be between 0 andarity()- 1- Returns:
- the sub-node
-
reverse
Creates a reversed version of this node.- Returns:
- a node with the reverse order of contained elements
-
insert
Inserts the given element at the given position in this node. The arraysiblingsis used for input as well as output. It must contain the left and right sibling of this node (if existing) at positions 0 and 2 when calling the method. After the method returns, there are two cases to consider:-
If the method returned
true(i.e. this node was split), the array contains the left sibling at position 0, the split node at position 1 and 2 and the right sibling at 3. - Otherwise the array contains (possibly modified versions of) left sibling at position 0, this node at position 1 and the right sibling at position 2.
- Parameters:
siblings- sibling array for input and outputpos- insertion positionval- value to insert- Returns:
trueif the node was split,falseotherwise
-
If the method returned
-
set
Replaces the element at the given position in this node with the given element.- Parameters:
pos- positionval- new value- Returns:
- resulting node
-
remove
Removes the element at the given position in this node. If this node is merged with one of its neighbors, the middle element of the result array isnull.- Parameters:
l- left neighbor, possiblynullr- right neighbor, possiblynullpos- position of the element to delete- Returns:
- three-element array with the new left neighbor, node and right neighbor
-
slice
Extracts a sub-tree containing the elements at positionsoff .. off + len - 1from the tree rooted at this node. This method is only called iflen < this.size()holds.- Parameters:
off- offset of first elementlen- number of elements- Returns:
- the sub-tree, possibly under-full
-
checkInvariants
long checkInvariants()Checks that this node does not violate any invariants.- Returns:
- this node's size
- Throws:
AssertionError- if an invariant was violated
-