Interface AtomSet

All Superinterfaces:
CloseableIterable<Atom>
All Known Subinterfaces:
InMemoryAtomSet
All Known Implementing Classes:
AbstractAtomSet, AbstractImmutableAtomSet, AbstractInMemoryAtomSet, DefaultInMemoryAtomSet, LinkedListAtomSet

public interface AtomSet extends CloseableIterable<Atom>
This interface represents a set of atoms. You can interpret this set like you want, disjunction or conjunction of atoms. However, in Graal, it is almost always interpreted as a conjunction.
Author:
Clément Sipieter (INRIA) clement@6pi.fr
  • Method Details

    • contains

      boolean contains(Atom atom) throws AtomSetException
      Returns true if this atom set contains the specified atom.
      Parameters:
      atom - the atom to search for
      Returns:
      true if this atom set contains the specified atom.
      Throws:
      AtomSetException - if the lookup cannot be performed
    • match

      Returns an iterator over atoms that match predicate and constants from the specified atom.
      Parameters:
      atom - the atom pattern to match
      Returns:
      an iterator over atoms.
      Throws:
      AtomSetException - if the match operation fails
    • match

      Returns an iterator over atoms that match predicate and constants from the specified atom.
      Parameters:
      atom - the atom pattern to match
      s - a substitution of Variable from atom into Term from this atom set.
      Returns:
      an iterator over atoms.
      Throws:
      AtomSetException - if the match operation fails
    • atomsByPredicate

      CloseableIterator<Atom> atomsByPredicate(Predicate predicate) throws AtomSetException
      Returns an iterator over all atoms with the specified predicate.
      Parameters:
      predicate - the predicate to search for
      Returns:
      an iterator over all atoms with the specified predicate.
      Throws:
      AtomSetException - if the lookup cannot be performed
    • atomsByTerm

      default CloseableIterator<Atom> atomsByTerm(Term term) throws AtomSetException
      Returns an iterator over all atoms which contain specified term.
      Parameters:
      term - the term to search for
      Returns:
      an iterator over all atoms which contain the specified term.
      Throws:
      AtomSetException - if the lookup cannot be performed
    • termsByPredicatePosition

      CloseableIterator<Term> termsByPredicatePosition(Predicate p, int position) throws AtomSetException
      Returns an iterator over terms which are in a specific position in at least one atom with the specified predicate.
      Parameters:
      p - the predicate to inspect
      position - the term position in atoms, positions starts from 0.
      Returns:
      an iterator over terms which appear in the specified position of the specified predicate.
      Throws:
      AtomSetException - if the lookup cannot be performed
    • getPredicates

      Set<Predicate> getPredicates() throws AtomSetException
      Returns a Set of all predicates in this atom set.
      Returns:
      a Set of all predicates.
      Throws:
      AtomSetException - if the predicate collection cannot be computed
    • predicatesIterator

      CloseableIterator<Predicate> predicatesIterator() throws AtomSetException
      Returns an iterator over all predicates in this atom set. Each predicate is iterated only once time.
      Returns:
      an iterator over all predicates.
      Throws:
      AtomSetException - if the predicate iterator cannot be produced
    • getTerms

      Set<Term> getTerms() throws AtomSetException
      Returns a Set of all terms in this atom set.
      Returns:
      a Set of all terms.
      Throws:
      AtomSetException - if the term collection cannot be computed
    • getVariables

      Set<Variable> getVariables() throws AtomSetException
      Returns a Set of all variables in this atom set.
      Returns:
      a Set of all variables.
      Throws:
      AtomSetException - if the variable collection cannot be computed
    • getConstants

      Set<Constant> getConstants() throws AtomSetException
      Returns a Set of all constants in this atom set.
      Returns:
      a Set of all constants.
      Throws:
      AtomSetException - if the constant collection cannot be computed
    • getLiterals

      Set<Literal> getLiterals() throws AtomSetException
      Returns a Set of all literals in this atom set.
      Returns:
      a Set of all literals.
      Throws:
      AtomSetException - if the literal collection cannot be computed
    • getTerms

      @Deprecated Set<Term> getTerms(Term.Type type) throws AtomSetException
      Deprecated.
      This method is deprecated since 1.3, use getVariables(), getConstants() or getLiterals() instead.

      Returns a Set of all terms of the specified type in this atom set.
      Parameters:
      type - the term type to filter on
      Returns:
      a collection of all terms of the specified type in this atom set.
      Throws:
      AtomSetException - if the term collection cannot be computed
    • termsIterator

      CloseableIterator<Term> termsIterator() throws AtomSetException
      Returns an iterator over all terms in this atom set. Each term is iterated only once time.
      Returns:
      an iterator over all terms.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • variablesIterator

      CloseableIterator<Variable> variablesIterator() throws AtomSetException
      Returns an iterator over all variables in this atom set. Each term is iterated only once time.
      Returns:
      an iterator over all variables.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • constantsIterator

      CloseableIterator<Constant> constantsIterator() throws AtomSetException
      Returns an iterator over all constants in this atom set. Each term is iterated only once time.
      Returns:
      an iterator over all constants.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • literalsIterator

      CloseableIterator<Literal> literalsIterator() throws AtomSetException
      Returns an iterator over all literals in this atom set. Each term is iterated only once time.
      Returns:
      an iterator over all literals.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • termsIterator

      Deprecated.
      This method is deprecated since 1.3, use variablesIterator(), constantsIterator() or literalsIterator() instead.

      Returns an iterator of all terms of the specified type in this atom set. Each term is iterated only once time.
      Parameters:
      type - the term type to filter on
      Returns:
      an iterator of all terms.
      Throws:
      AtomSetException - if the iterator cannot be produced
    • isSubSetOf

      @Deprecated boolean isSubSetOf(AtomSet atomset) throws AtomSetException
      Deprecated.
      Use AtomSets.contains instead. Check if all atoms of this AtomSet are also contained in the specified AtomSet.
      Parameters:
      atomset - the candidate superset
      Returns:
      true if all atoms of this AtomSet are also contained in the specified atomset, false otherwise.
      Throws:
      AtomSetException - if the subset test cannot be performed
    • size

      int size() throws AtomSetException
      Returns the number of atoms in this set.
      Returns:
      the number of atoms in the set
      Throws:
      AtomSetException - if the size cannot be computed
    • isEmpty

      boolean isEmpty() throws AtomSetException
      Returns whether this atom set contains no atom.
      Returns:
      true if this atom set is empty, false otherwise.
      Throws:
      AtomSetException - if the emptiness check cannot be performed
    • add

      boolean add(Atom atom) throws AtomSetException
      Add the specified atom to this atom set if is not already present.
      Parameters:
      atom - the atom to be added to this atom set
      Returns:
      true if this atom set did not already contain the specified atom
      Throws:
      AtomSetException - if the atom cannot be added
    • addAll

      boolean addAll(CloseableIterator<? extends Atom> atoms) throws AtomSetException
      Add the specified atom stream to this atom set.
      Parameters:
      atoms - the atom stream to add
      Returns:
      true if this atomset changed as a result of the call.
      Throws:
      AtomSetException - if the atoms cannot be added
    • addAll

      boolean addAll(AtomSet atoms) throws AtomSetException
      Adds all atoms from the specified atom set.
      Parameters:
      atoms - the atom set to add
      Returns:
      true if this atomset changed as a result of the call.
      Throws:
      AtomSetException - if the atoms cannot be added
    • remove

      boolean remove(Atom atom) throws AtomSetException
      Remove the specified atom from this this atom set.
      Parameters:
      atom - the atom to be removed
      Returns:
      true if this atom set contained the specified atom.
      Throws:
      AtomSetException - if the atom cannot be removed
    • removeWithoutCheck

      default void removeWithoutCheck(Atom atom) throws AtomSetException
      Remove the specified atom from this this atom set.
      Parameters:
      atom - the atom to be removed
      Throws:
      AtomSetException - if the atom cannot be removed
    • removeAll

      boolean removeAll(CloseableIterator<? extends Atom> atoms) throws AtomSetException
      Remove the specified atom stream from this atom set.
      Parameters:
      atoms - the atom stream to be removed
      Returns:
      true if this atomset changed as a result of the call. In many implementations, the return value is only true since it's time consuming to test the effective modification of the store (e.g. RDBMS, RDF4J...)
      Throws:
      AtomSetException - if the atoms cannot be removed
    • removeAll

      boolean removeAll(AtomSet atoms) throws AtomSetException
      Removes all atoms contained in the specified atom set.
      Parameters:
      atoms - the atoms to remove
      Returns:
      true if this atom set changed as a result of the call
      Throws:
      AtomSetException - if the atoms cannot be removed
    • clear

      void clear() throws AtomSetException
      Removes all atoms from this atom set.
      Throws:
      AtomSetException - if the set cannot be cleared
    • iterator

      CloseableIterator<Atom> iterator()
      Returns an iterator over the atoms in this atom set.
      Specified by:
      iterator in interface CloseableIterable<Atom>
      Returns:
      an iterator over the atoms in this atom set.
    • getFreshSymbolGenerator

      TermGenerator getFreshSymbolGenerator()
      Returns the fresh symbol generator associated with this atom set.
      Returns:
      the symbol generator used by this atom set
    • containsTerm

      default boolean containsTerm(Term t) throws AtomSetException
      Check if there exists an atom that contains the term t
      Parameters:
      t - the term that we want to check if it exists
      Returns:
      true if there exists an atom with the term t, false otherwise
      Throws:
      AtomSetException - if the lookup cannot be performed