Class LongLabel


  • public class LongLabel
    extends Label
    A Label implementation that stores match/mismatch data in a single long for compactness and speed. The use of an long as storage, however, creates a limit to the size of the label. See MAX_CARDINALITY.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_CARDINALITY
      The maximum cardinality of a long label, which is limited by the number of bits in a long in Java.
    • Constructor Summary

      Constructors 
      Constructor Description
      LongLabel​(long bits, int cardinality)  
      LongLabel​(Label other)
      Create a LongLabel by copying the contents of other.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean allMatching()  
      java.util.Iterator<Label> descendantIterator()
      The "descendants" of a label are the set of labels with the same "mismatch" entries, but with one or more of the "match" entries changed into a "mismatch" entry.
      boolean equals​(java.lang.Object other)  
      int getCardinality()  
      int hashCode()  
      Label intersect​(Label other)
      Create a new label for which each location is marked as a match if both this label and otherLabel are marked match, otherwise mismatch.
      boolean isDescendantOf​(Label possibleDescendant)
      Determine if this label is the "descendant" of possibleAncestor.
      long labelBits()  
      boolean matches​(int index)
      Determine if the given index is marked as a match or a mismatch.
      int numMatches()  
      java.lang.String toString()  
      Label union​(Label other)
      Create a new label for which each location is marked as a match if either this label or other is marked match, otherwise mismatch.
      • Methods inherited from class java.lang.Object

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

      • MAX_CARDINALITY

        public static final int MAX_CARDINALITY
        The maximum cardinality of a long label, which is limited by the number of bits in a long in Java.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LongLabel

        public LongLabel​(long bits,
                         int cardinality)
        Parameters:
        bits - binary label represented by bits in a long
        cardinality - cardinality of the label
      • LongLabel

        public LongLabel​(Label other)
        Create a LongLabel by copying the contents of other.
    • Method Detail

      • labelBits

        public long labelBits()
        Returns:
        A long whose 1 bits represent the mismatches and 0 bits represent the matches in this label.
      • getCardinality

        public int getCardinality()
        Specified by:
        getCardinality in class Label
        Returns:
        The number of attributes represented in this label.
      • matches

        public boolean matches​(int index)
        Description copied from class: Label
        Determine if the given index is marked as a match or a mismatch.
        Specified by:
        matches in class Label
        Parameters:
        index - Index of the attribute being represented
        Returns:
        True if the index is a match, false otherwise.
      • numMatches

        public int numMatches()
        Specified by:
        numMatches in class Label
        Returns:
        The total number of matches marked in this label.
      • intersect

        public Label intersect​(Label other)
        Description copied from class: Label
        Create a new label for which each location is marked as a match if both this label and otherLabel are marked match, otherwise mismatch. In other words, keep all mismatches from both labels.
        Specified by:
        intersect in class Label
        Parameters:
        other - the label to intersect with this one
        Returns:
        an intersected label
      • union

        public Label union​(Label other)
        Description copied from class: Label
        Create a new label for which each location is marked as a match if either this label or other is marked match, otherwise mismatch. In other words, keep all matches from both labels.
        Specified by:
        union in class Label
      • allMatching

        public boolean allMatching()
        Specified by:
        allMatching in class Label
        Returns:
        true if every feature of this label is a match (i.e. this is the top of the lattice; false otherwise
      • toString

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

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.util.Iterator<Label> descendantIterator()
        Description copied from class: Label
        The "descendants" of a label are the set of labels with the same "mismatch" entries, but with one or more of the "match" entries changed into a "mismatch" entry. For example, the children of {match, mismatch, mismatch, match} are:
        • {mismatch, mismatch, mismatch, match},
        • {match, mismatch, mismatch, mismatch}, and
        • {mismatch, mismatch, mismatch, mismatch}
        .
        Specified by:
        descendantIterator in class Label
        Returns:
        An iterator over the label descendants
      • isDescendantOf

        public boolean isDescendantOf​(Label possibleDescendant)
        Description copied from class: Label
        Determine if this label is the "descendant" of possibleAncestor. This label is a descendant of the other label if every mismatching entry in the other label is also a mismatching entry in this label. Any label is also a descendant of itself.
        Specified by:
        isDescendantOf in class Label
        Parameters:
        possibleDescendant - possible label ancestor
        Returns:
        true if possibleAncestor is an ancestor of this label; false otherwise.