Class Selection<L extends Language<L>>

java.lang.Object
io.github.vecbricks.jegg.Selection<L>
Type Parameters:
L - the language

public final class Selection<L extends Language<L>> extends Object
One node chosen per class, for the classes some roots reach: the result of extraction over several roots at once, where a subterm two roots share is one choice paid once. Reading it back as terms gives a DAG, one Extracted object per class.

Held as a sorted array of class ids beside the chosen nodes, no map and no boxed id; the map view nodes() is built when asked for.

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    The sum of the chosen nodes' own costs, each class once.
    node(int eclass)
    The node chosen for this class; the class must be one the roots reach.
    The classes the selection covers, in id order, with their nodes, read-only.
    The roots the selection was made for, as root ids.
    int
    How many classes the selection covers.
    The selection's terms, one per root, sharing subterm objects where the roots share classes.
     

    Methods inherited from class Object

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

    • roots

      public IntList roots()
      The roots the selection was made for, as root ids.
      Returns:
      the canonical ids of the roots, in the order given to the extractor
    • node

      public L node(int eclass)
      The node chosen for this class; the class must be one the roots reach.
      Parameters:
      eclass - the canonical id of a class in the selection
      Returns:
      the node chosen for the class
      Throws:
      IllegalArgumentException - if the class is not in the selection
    • nodes

      public Map<Integer,L> nodes()
      The classes the selection covers, in id order, with their nodes, read-only.
      Returns:
      a fresh unmodifiable map from class id to its chosen node
    • cost

      public double cost()
      The sum of the chosen nodes' own costs, each class once.
      Returns:
      the selection's cost, finite and non-negative
    • size

      public int size()
      How many classes the selection covers.
      Returns:
      the number of classes, which is also the number of chosen nodes
    • terms

      public List<Extracted<L>> terms()
      The selection's terms, one per root, sharing subterm objects where the roots share classes.
      Returns:
      a fresh list with the term of each root, in the order of roots()
    • toString

      public String toString()
      Overrides:
      toString in class Object