Appends an element to the tree.
Appends an element to the tree.
the element to append
this same tree
Appends multiple elements to the tree
Appends multiple elements to the tree
the elements to append
Appends all elements of a collection to the tree.
Appends all elements of a collection to the tree. The elements are appended in the order in which they are contained in the argument.
the collection whose elements should be appended
Queries an element at a given index.
Queries an element at a given index. Throws an exception if the idx
argument
is negative or greater than or equal to the size of the tree.
the index of the element
the element at the given index
Tests whether an element is contained in the tree.
Tests whether an element is contained in the tree. This is a constant time operation.
the element to look for
true
if the element is included in the tree, false
otherwise
Tests whether a given sub-sequence is contained in the tree.
Tests whether a given sub-sequence is contained in the tree. This is a very fast operation taking O(|xs|).
the sequence to look for
true
if the sequence is included in the tree, false
otherwise
Queries whether the collection is empty (has zero elements)
Queries whether the collection is empty (has zero elements)
The length of the collection in this tree.
The length of the collection in this tree. Same as size
Queries whether the collection non-empty (has one or more elements)
Queries whether the collection non-empty (has one or more elements)
Queries the number of elements in the tree
Queries the number of elements in the tree
Creates a new snake through the tree from a given initial sequence.
Creates a new snake through the tree from a given initial sequence.
This initial sequence must be contained in the tree (e.g. containsSlice
must return true
),
otherwise an exception is thrown.
To construct a snake from a particular index range of the tree, use
snake(view(from, until))
. Note that because the sequence might occur multiple
times in the corpus, this does not guarantee any particular resulting index
into the tree.
the sequence to begin with
a new snake whose content is init
Converts this tree into another collection by copying all elements.
Converts this tree into another collection by copying all elements.
the target collection type
the builder factory which determines the target collection type
a new independent collection containing all elements of this tree
Helper method to export the tree to GraphViz DOT format.
Helper method to export the tree to GraphViz DOT format. This is mostly for debugging or demonstration purposes and might not be particularly efficient or suitable for large trees.
whether to include the tail (suffix-pointer) edges or not
a string representation in DOT format
Provides a view of a range of the underlying buffer.
Provides a view of a range of the underlying buffer. Technically, because the underlying buffer is mutable, this view would be subject to mutations as well until a copy is built. However, since the tree is append-only, the portion visible in the view will never change.
Note that, like the view
method in collection.mutable.Buffer
, the range is
clipped to the length of the underlying buffer _at this moment_. For example,
if the buffer currently has 6 elements, a view(7,8)
is treated as view(6,6)
and will always be empty. Therefore it is save to treat the view as immutable.
the start index into the collection
the stop index (exclusive) into the collection
a view of the given range.
A mutable data append-only suffix tree that support efficient searching for sub-sequences.
the element type of the structure