Class LinkedLatticeNode<T extends Supracontext>

  • Type Parameters:
    T - The implementation of Supracontext to be stored in this node.
    All Implemented Interfaces:
    Supracontext

    public class LinkedLatticeNode<T extends Supracontext>
    extends java.lang.Object
    implements Supracontext
    This class is a decorator which wraps a Supracontext and adds the functionality of a linked node used in certain lattice-filling algorithms. An index is also provided for use in determining when the node was created.
    • Constructor Summary

      Constructors 
      Constructor Description
      LinkedLatticeNode​(T supra)
      Create a new node containing the given supracontext.
    • Constructor Detail

      • LinkedLatticeNode

        public LinkedLatticeNode​(T supra)
        Create a new node containing the given supracontext. The index is set to -1.
        Parameters:
        supra - Supracontext to store in this node.
    • Method Detail

      • insertAfter

        public LinkedLatticeNode<T> insertAfter​(Subcontext sub,
                                                int ind)
        Create a new node by copying this one, adding the given subcontext and setting the index to that provided. Insert the new node between this node and its next node by setting the new node to be the next node and setting the previous next node to be the new node's next node.
        Parameters:
        sub - Subcontext to insert into the copied Supracontext
        ind - index of new node
      • getNext

        public LinkedLatticeNode<T> getNext()
        Returns:
        the next node linked to by this node
      • setNext

        public void setNext​(LinkedLatticeNode<T> next)
        Set the next node linked to by this node
        Parameters:
        next - the node to link to
      • getIndex

        public int getIndex()
        Returns:
        The index of this node.
      • incrementCount

        public void incrementCount()
        Increases count by one.
      • decrementCount

        public void decrementCount()
        Decreases the count by one; if this reaches 0, then this Supracontext should be discarded (by the caller).
        Throws:
        java.lang.IllegalStateException - if the count is already zero.
      • getSupracontext

        public T getSupracontext()
        Returns:
        The supracontext contained in this node.
      • copy

        public Supracontext copy()
        Description copied from interface: Supracontext
        Return an exact, deep copy of the supracontext. The new object should be an instance of the same class as the calling object.
        Specified by:
        copy in interface Supracontext
        Returns:
        a deep copy of this supracontext.
      • add

        public void add​(Subcontext sub)
        Description copied from interface: Supracontext
        Add a subcontext to this supracontext.
        Specified by:
        add in interface Supracontext
        Parameters:
        sub - Subcontext to add to the supracontext.
      • getData

        public java.util.Set<Subcontext> getData()
        Specified by:
        getData in interface Supracontext
        Returns:
        an unmodifiable view of the set of subcontexts contained in this supracontext.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Supracontext
        Returns:
        true if this supracontext contains no subcontexts; false otherwise.
      • getCount

        public java.math.BigInteger getCount()
        Specified by:
        getCount in interface Supracontext
        Returns:
        the number of copies of this supracontext contained in the lattice
      • setCount

        public void setCount​(java.math.BigInteger count)
        Description copied from interface: Supracontext
        Set the count of the supracontext.
        Specified by:
        setCount in interface Supracontext
        Parameters:
        count - the count
      • getContext

        public Label getContext()
        Description copied from interface: Supracontext
        Retrieve the supracontextual context, represented with a Label object. Label mismatches should be interpreted as "contained subcontexts may or may not match for this attribute, while matches should be regarded as "all contained subcontexts matched for this attribute". The running time for this default implementation is linear in the number of contained subcontexts.
        Specified by:
        getContext in interface Supracontext
        Returns:
        The context for this supracontext, or null if the subcontexts are empty
      • equals

        public boolean equals​(java.lang.Object other)
        Description copied from interface: Supracontext
        Two Supracontexts are equal if they are of the same class and contain the same subcontexts.
        Specified by:
        equals in interface Supracontext
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Description copied from interface: Supracontext
        The hashcode depends solely on the set of subcontexts contained in a supracontext.
        Specified by:
        hashCode in interface Supracontext
        Overrides:
        hashCode in class java.lang.Object
      • toString

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