ImmutableTree<T> class
final
An immutable tree with an optional value at every node and children by ChildKey.
Properties
-
entries
→ Iterable<MapEntry<Path, T>>
-
Every value with its path, in order.
no setter
-
hashCode
→ int
-
The hash code for this object.
no setteroverride
-
isEmpty
→ bool
-
Whether there is no value anywhere in the tree.
no setter
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
value
→ T?
-
The value at the root, or null.
final
Methods
-
containsMatchingValue(bool predicate(T value))
→ bool
-
Whether any value in the tree matches
predicate.
-
findOnPath<V>(Path path, V? fn(Path path, T value))
→ V?
-
Calls
fn on the values along path from the root until it returns non-null.
-
findRootMostMatchingPathAndValue(Path relativePath, bool predicate(T value))
→ PathAndValue<T>?
-
The root-most value on
relativePath for which predicate holds, with its path.
-
findRootMostValueAndPath(Path relativePath)
→ PathAndValue<T>?
-
The root-most value on
relativePath, with its path.
-
fold<V>(V fn(Path path, T? value, Map<ChildKey, V> children))
→ V
-
Folds the tree bottom-up:
fn gets each node's path, value and its children's results.
-
foldValues<R>(R initial, R fn(Path path, T value, R accumulator))
→ R
-
Folds every value with an accumulator, starting from
initial (Android's fold).
-
forEach(void fn(Path path, T value))
→ void
-
Calls
fn on every value, depth first.
-
forEachChild(void fn(ChildKey key, T value))
→ void
-
Calls
fn on the value of every immediate child that has one.
-
forEachOnPath(Path path, void fn(Path path, T value))
→ ImmutableTree<T>
-
Calls
fn on the values along path; returns the subtree at path.
-
get(Path relativePath)
→ T?
-
The value at
relativePath, or null.
-
getChild(ChildKey key)
→ ImmutableTree<T>
-
The immediate child
key (empty when absent).
-
leafMostValue(Path relativePath)
→ T?
-
The leaf-most value on
relativePath, or null.
-
leafMostValueMatching(Path relativePath, bool predicate(T value))
→ T?
-
The leaf-most value on
relativePath matching predicate, or null.
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(Path relativePath)
→ ImmutableTree<T>
-
A tree without the value and subtree at
relativePath.
-
rootMostValue(Path relativePath)
→ T?
-
The root-most value on
relativePath, or null.
-
rootMostValueMatching(Path relativePath, bool predicate(T value))
→ T?
-
The root-most value on
relativePath matching predicate, or null.
-
set(Path relativePath, T? toSet)
→ ImmutableTree<T>
-
A tree with
toSet at relativePath.
-
setTree(Path relativePath, ImmutableTree<T> newTree)
→ ImmutableTree<T>
-
A tree with
newTree at relativePath.
-
subtree(Path relativePath)
→ ImmutableTree<T>
-
The subtree at
relativePath (empty when absent).
-
toString()
→ String
-
A string representation of this object.
override