- Companion
- object
Value members
Abstract methods
Prepends an element to the tree.
Prepends an element to the tree.
- Value Params
- b
the element to prepend
- m
the measure used to update the tree's measure
- Returns
the new tree with the element prepended
Appends an element to the tree.
Appends an element to the tree.
- Value Params
- b
the element to append
- m
the measure used to update the tree's structure
- Returns
the new tree with the element appended
Traverses the tree until a predicate on an element becomes true
, and then returns that
element. Note that if pred
returns false
for every element, the last element in the
tree is returned (rather than a runtime exception being thrown).
Traverses the tree until a predicate on an element becomes true
, and then returns that
element. Note that if pred
returns false
for every element, the last element in the
tree is returned (rather than a runtime exception being thrown).
If the tree is empty, this throws a runtime exception.
- Value Params
- pred
a test function applied to the elements of the tree from left to right, until a the test returns
true
.
- Returns
the discerning element
Returns the first (left-most) element in the tree. Throws a runtime exception if performed on an empty tree.
Returns the first (left-most) element in the tree. Throws a runtime exception if performed on an empty tree.
- Returns
the head element
Returns the first (left-most) element in the tree as an option.
Returns the first (left-most) element in the tree as an option.
- Returns
the head element (
Some
), orNone
if the tree is empty
Drops the last element of the tree.
Drops the last element of the tree.
- Returns
the tree where the last element has been removed
Queries whether the tree is empty or not
Queries whether the tree is empty or not
- Returns
true
if the tree is empty
Creates an Iterator
over the elements of the tree
Creates an Iterator
over the elements of the tree
- Returns
a fresh
Iterator
for the tree elements
Returns the last (right-most) element in the tree. Throws a runtime exception if performed on an empty tree.
Returns the last (right-most) element in the tree. Throws a runtime exception if performed on an empty tree.
- Returns
the last element
Returns the last (right-most) element in the tree as an option.
Returns the last (right-most) element in the tree as an option.
- Returns
the last element (
Some
), orNone
if the tree is empty
Queries the measure of the tree, which might be its size or sum
Queries the measure of the tree, which might be its size or sum
- Returns
the measure of the tree
Same as span1
, but prepends the discerning element to the right tree, returning the left and right tree.
Unlike span1
, this is an allowed operation on an empty tree.
Same as span1
, but prepends the discerning element to the right tree, returning the left and right tree.
Unlike span1
, this is an allowed operation on an empty tree.
- Value Params
- pred
a test function applied to the elements of the tree from left to right, until a the test returns
false
.
- Returns
the split tree, as a
Tuple2
with the left and the right tree
Traverses the tree until a predicate on an element becomes false
, and then splits the tree,
returning the elements before that element (the prefix for which the predicate holds),
the element itself (the first for which the predicate does not hold), and the remaining elements.
Traverses the tree until a predicate on an element becomes false
, and then splits the tree,
returning the elements before that element (the prefix for which the predicate holds),
the element itself (the first for which the predicate does not hold), and the remaining elements.
This method is somewhat analogous to the span
method in standard Scala collections, the difference
being that the predicate tests the tree's measure and not individual elements.
Note that the returned discerning element corresponds to the last element in the tree, if
pred
returns true
for every element (rather than a runtime exception being thrown).
If the tree is empty, this throws a runtime exception.
- Value Params
- pred
a test function applied to the elements of the tree from left to right, until a the test returns
true
.
- Returns
the split tree, as a
Tuple3
with the left tree, the discerning element, and the right tree
Returns a copy of the tree with the first (head) element removed. Throws a runtime exception if performed on an empty tree.
Returns a copy of the tree with the first (head) element removed. Throws a runtime exception if performed on an empty tree.
- Value Params
- m
the measure used to update the tree's structure
- Returns
the new tree with the first element removed