Class AbstractNode

java.lang.Object
io.crums.util.mrkl.index.AbstractNode
Direct Known Subclasses:
Node

public abstract class AbstractNode extends Object
Breadth-first coordinates of a node in a Merkle tree.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Stateless factory for "index" of instances of this class with no additional data.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractNode(int level, int index)
    Base constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Equality semantics are governed by coordinates and handedness.
    final int
    Consistent with equals(Object).
    final int
    Returns this node's index (at this level).
    final boolean
    Determines whether this node is at level zero.
    final boolean
    Determines whether this node is the left child of its parent.
    abstract boolean
    Determines whether this node is the right child of its parent.
    final int
    Returns this node's level.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • level

      public final int level()
      Returns this node's level. Levels are counted from the bottom up: zero at the leaves, maximum at root.
    • isLeaf

      public final boolean isLeaf()
      Determines whether this node is at level zero.
    • index

      public final int index()
      Returns this node's index (at this level).
    • isLeft

      public final boolean isLeft()
      Determines whether this node is the left child of its parent. Note, for closure reasons the root node is defined to be left.
    • isRight

      public abstract boolean isRight()
      Determines whether this node is the right child of its parent.

      Implementations should be marked final.

    • equals

      public final boolean equals(Object o)
      Equality semantics are governed by coordinates and handedness.
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()

      Consistent with equals(Object).

      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      "(" + level() + ":" + index() + ")"