T
- type of the tree's valuespublic static final class Tree.Empty<T> extends Object implements Tree<T>, Serializable
Tree.Empty<T>, Tree.Node<T>, Tree.Order
Modifier and Type | Method and Description |
---|---|
String |
draw()
Creates a neat 2-dimensional drawing of a tree.
|
boolean |
equals(Object o)
In Vavr there are four basic classes of collections:
Seq (sequential elements)
Set (distinct elements)
Map (indexed elements)
Multimap (indexed collections)
Two collection instances of these classes are equal if and only if both collections
belong to the same basic collection class (Seq, Set, Map or Multimap)
contain the same elements
have the same element order, if the collections are of type Seq
Two Map/Multimap elements, resp.
|
List<Tree.Node<T>> |
getChildren()
Returns the children of this tree.
|
T |
getValue()
Gets the value of this tree.
|
int |
hashCode()
Returns the hash code of this collection.
|
static <T> Tree.Empty<T> |
instance() |
boolean |
isEmpty()
Checks if this Traversable is empty.
|
boolean |
isLeaf()
Checks if this Tree is a leaf.
|
T |
last()
Dual of Traversable.head(), returning the last element.
|
int |
length()
Computes the number of elements of this Traversable.
|
String |
toLispString()
Creates a Lisp-like representation of this
Tree . |
String |
toString()
Clarifies that values have a proper toString() method implemented.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
branchCount, build, collect, collector, distinct, distinctBy, distinctBy, drop, dropRight, dropUntil, dropWhile, empty, fill, fill, filter, flatMap, foldRight, groupBy, grouped, hasDefiniteSize, head, init, initOption, isAsync, isBranch, isDistinct, isLazy, isSequential, isTraversableAgain, iterator, iterator, leafCount, map, narrow, nodeCount, of, of, of, of, ofAll, ofAll, orElse, orElse, partition, peek, recurse, reject, replace, replaceAll, retainAll, scan, scanLeft, scanRight, slideBy, sliding, sliding, span, stringPrefix, tabulate, tail, tailOption, take, takeRight, takeUntil, takeWhile, transform, traverse, traverse, unzip, unzip3, values, values, zip, zipAll, zipWith, zipWithIndex, zipWithIndex
arrangeBy, average, containsAll, count, existsUnique, find, findLast, foldLeft, forEachWithIndex, get, headOption, isOrdered, isSingleValued, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, narrow, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sum
fold, reduce, reduceOption
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, narrow, out, out, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
public static <T> Tree.Empty<T> instance()
public List<Tree.Node<T>> getChildren()
Tree
getChildren
in interface Tree<T>
public boolean isEmpty()
Traversable
public int length()
Traversable
Same as Traversable.size()
.
length
in interface Traversable<T>
public boolean isLeaf()
Tree
public T last()
Traversable
last
in interface Traversable<T>
public boolean equals(Object o)
Traversable
Notes:
equals
in interface Traversable<T>
equals
in interface Tree<T>
equals
in interface Value<T>
equals
in class Object
o
- an object, may be nullpublic int hashCode()
Traversable
int hash = 1;
for (T t : this) { hash = hash * 31 + Objects.hashCode(t); }
Collections with arbitrary iteration order are hashed in a way such that the hash of a fixed number of elements is independent of their iteration order.
int hash = 1;
for (T t : this) { hash += Objects.hashCode(t); }
Please note that the particular hashing algorithms may change in a future version of Vavr.
public final class Hashed<K> {
private final K key;
private final Lazy<Integer> hashCode;
public Hashed(K key) {
this.key = key;
this.hashCode = Lazy.of(() -> Objects.hashCode(key));
}
public K key() {
return key;
}
@Override
public boolean equals(Object o) {
if (o == key) {
return true;
} else if (key != null && o instanceof Hashed) {
final Hashed that = (Hashed) o;
return key.equals(that.key);
} else {
return false;
}
}
@Override
public int hashCode() {
return hashCode.get();
}
@Override
public String toString() {
return "Hashed(" + (key == null ? "null" : key.toString()) + ")";
}
}
public String toString()
Value
See Object.toString().
public String toLispString()
Tree
Tree
.toLispString
in interface Tree<T>
Tree
as Lisp-string, i.e. represented as list of lists.Copyright © 2021. All Rights Reserved.