Package org.basex.query.util.fingertree
Interface Node<N,E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
arity()
Number of children of this node.long
checkInvariants()
Checks that this node does not violate any invariants.N
getSub(int pos)
Returns the sub-node at the given position in this node.boolean
insert(Node<N,E>[] siblings, long pos, E val)
Inserts the given element at the given position in this node.NodeLike<N,E>[]
remove(Node<N,E> l, Node<N,E> r, long pos)
Removes the element at the given position in this node.Node<N,E>
reverse()
Creates a reversed version of this node.Node<N,E>
set(long pos, E val)
Replaces the element at the given position in this node with the given element.long
size()
Number of elements in this node.NodeLike<N,E>
slice(long off, long len)
Extracts a subtree containing the elements at positionsoff .. off + len - 1
from the tree rooted at this node.
-
-
-
Method Detail
-
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
N getSub(int pos)
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
Node<N,E> reverse()
Creates a reversed version of this node.- Returns:
- a node with the reverse order of contained elements
-
insert
boolean insert(Node<N,E>[] siblings, long pos, E val)
Inserts the given element at the given position in this node. The arraysiblings
is 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:
true
if the node was split,false
otherwise
-
If the method returned
-
set
Node<N,E> set(long pos, E val)
Replaces the element at the given position in this node with the given element.- Parameters:
pos
- positionval
- new value- Returns:
- resulting node
-
remove
NodeLike<N,E>[] remove(Node<N,E> l, Node<N,E> r, long pos)
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, possiblynull
r
- right neighbor, possiblynull
pos
- position of the element to delete- Returns:
- three-element array with the new left neighbor, node and right neighbor
-
slice
NodeLike<N,E> slice(long off, long len)
Extracts a subtree containing the elements at positionsoff .. off + len - 1
from 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 subtree, 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
-
-