Example #1
0
 /**
  * Constructs a rose tree branch.
  *
  * @param value A value.
  * @param children A non-empty list of children.
  * @throws NullPointerException if children is null
  * @throws IllegalArgumentException if children is empty
  */
 public Node(T value, List<Node<T>> children) {
   Objects.requireNonNull(children, "children is null");
   this.value = value;
   this.children = children;
   this.size = Lazy.of(() -> 1 + children.foldLeft(0, (acc, child) -> acc + child.length()));
   this.hashCode = 31 * 31 + 31 * Objects.hashCode(value) + Objects.hashCode(children);
 }
 public int hashCode() {
   return hash ^ Objects.hashCode(value);
 }