Class AbstractNode

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

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

    Fields
    Modifier and Type Field Description
    static TreeIndex.NodeFactory<AbstractNode> FACTORY
    Stateless factory.
  • Constructor Summary

    Constructors
    Modifier Constructor Description
    protected AbstractNode​(int level, int index)  
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object o)
    Equality semantics are governed by coordinates and handedness.
    int hashCode()  
    int index()
    Returns this node's index (at this level).
    boolean isLeaf()
    Determines whether this node is at level zero.
    boolean isLeft()
    Determines whether this node is the left child of its parent.
    abstract boolean isRight()
    Determines whether this node is the right child of its parent.
    int level()
    Returns this node's level.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • AbstractNode

      protected AbstractNode​(int level, int index) throws java.lang.IndexOutOfBoundsException
      Throws:
      java.lang.IndexOutOfBoundsException
  • 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​(java.lang.Object o)
      Equality semantics are governed by coordinates and handedness.
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object