Module dev.civl.mc

Class SeqSet.Node

java.lang.Object
dev.civl.mc.util.IF.SeqSet.Node
Enclosing class:
SeqSet

class SeqSet.Node extends Object
A node in the tree representation. Each node represents a single integer. A minimal element of the set corresponds to a path in the tree from the root to a leaf node.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) SeqSet.Node[]
    The children nodes.
    (package private) SortedSet<Integer>
    The set consisting of the indexes of the children of this node.
    (package private) int
    The index of this node in the parent's list of children.
    (package private) SeqSet.Node
    The parent node in the tree, or null if this is the root.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Node(SeqSet.Node parent, int index)
    Creates new node with given index, empty set of childrenIndexes.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    (package private) boolean
    hasChild(int index)
    Does this node have a child with the given index?
    (package private) boolean
    Is this node a leaf node? A node is a leaf iff it has 0 children.
    (package private) Iterator<Integer>
    Returns a new iterator over childrenIndexes.
    (package private) boolean
    setChild(int index)
    If this node already contains the child at index, does nothing and returns false.
     

    Methods inherited from class java.lang.Object

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

    • parent

      SeqSet.Node parent
      The parent node in the tree, or null if this is the root.
    • index

      int index
      The index of this node in the parent's list of children. If this is the root node (the only node with no parent), -1.
    • childrenIndexes

      SortedSet<Integer> childrenIndexes
      The set consisting of the indexes of the children of this node.
    • children

      SeqSet.Node[] children
      The children nodes. If i is in childrenIndexes, then children[i] will be a non-null Node with index i and is considered "active". Otherwise, children[i] may or may not be null; if not null, the child is considered "inactive". An inactive child can be reactivated at some future point when this set changes. This is an optimization---it should be functionally equivalent but faster than setting children[i] to null and creating a new Node.
  • Constructor Details

    • Node

      Node(SeqSet.Node parent, int index)
      Creates new node with given index, empty set of childrenIndexes.
      Parameters:
      parent - the parent node or null if the new node will be a root
      index - the index for the new node: should be -1 for a root, and nonnegative for any other node---the index of this new node in its parent
  • Method Details

    • hasChild

      boolean hasChild(int index)
      Does this node have a child with the given index?
      Parameters:
      index - a nonnegative integer
      Returns:
      true iff this node has a child with that index
    • isLeaf

      boolean isLeaf()
      Is this node a leaf node? A node is a leaf iff it has 0 children.
      Returns:
      true iff this is a leaf node
    • setChild

      boolean setChild(int index)
      If this node already contains the child at index, does nothing and returns false. Otherwise, the node is created or reactivated and cleared, and the child index is added to this node's childrenIndexes.
      Parameters:
      index - index of child
      Returns:
      true iff the child was not already there
    • clear

      void clear()
    • iterator

      Iterator<Integer> iterator()
      Returns a new iterator over childrenIndexes.
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object