Interface InMemoryAtomSet

All Superinterfaces:
AtomSet, CloseableIterable<Atom>, CloseableIterableWithoutException<Atom>, Iterable<Atom>
All Known Implementing Classes:
AbstractInMemoryAtomSet, DefaultInMemoryAtomSet, LinkedListAtomSet

public interface InMemoryAtomSet extends AtomSet, CloseableIterableWithoutException<Atom>
This interface represents an InMemory AtomSet. So, AtomSet methods are redefined without the ability to throw exception.
Author:
Clément Sipieter (INRIA) <clement@6pi.fr>
  • Method Details

    • contains

      boolean contains(Atom atom)
      Description copied from interface: AtomSet
      Returns true if this atom set contains the specified atom.
      Specified by:
      contains in interface AtomSet
      Parameters:
      atom - the atom to search for
      Returns:
      true if this atom set contains the specified atom.
    • match

      Description copied from interface: AtomSet
      Returns an iterator over atoms that match predicate and constants from the specified atom.
      Specified by:
      match in interface AtomSet
      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.
    • atomsByPredicate

      Description copied from interface: AtomSet
      Returns an iterator over all atoms with the specified predicate.
      Specified by:
      atomsByPredicate in interface AtomSet
      Parameters:
      p - the predicate to search for
      Returns:
      an iterator over all atoms with the specified predicate.
    • termsByPredicatePosition

      CloseableIteratorWithoutException<Term> termsByPredicatePosition(Predicate p, int position)
      Description copied from interface: AtomSet
      Returns an iterator over terms which are in a specific position in at least one atom with the specified predicate.
      Specified by:
      termsByPredicatePosition in interface AtomSet
      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.
    • getPredicates

      Set<Predicate> getPredicates()
      Description copied from interface: AtomSet
      Returns a Set of all predicates in this atom set.
      Specified by:
      getPredicates in interface AtomSet
      Returns:
      a Set of all predicates.
    • predicatesIterator

      Description copied from interface: AtomSet
      Returns an iterator over all predicates in this atom set. Each predicate is iterated only once time.
      Specified by:
      predicatesIterator in interface AtomSet
      Returns:
      an iterator over all predicates.
    • getTerms

      Set<Term> getTerms()
      Description copied from interface: AtomSet
      Returns a Set of all terms in this atom set.
      Specified by:
      getTerms in interface AtomSet
      Returns:
      a Set of all terms.
    • getVariables

      Set<Variable> getVariables()
      Description copied from interface: AtomSet
      Returns a Set of all variables in this atom set.
      Specified by:
      getVariables in interface AtomSet
      Returns:
      a Set of all variables.
    • getConstants

      Set<Constant> getConstants()
      Description copied from interface: AtomSet
      Returns a Set of all constants in this atom set.
      Specified by:
      getConstants in interface AtomSet
      Returns:
      a Set of all constants.
    • getLiterals

      Set<Literal> getLiterals()
      Description copied from interface: AtomSet
      Returns a Set of all literals in this atom set.
      Specified by:
      getLiterals in interface AtomSet
      Returns:
      a Set of all literals.
    • termsIterator

      Description copied from interface: AtomSet
      Returns an iterator over all terms in this atom set. Each term is iterated only once time.
      Specified by:
      termsIterator in interface AtomSet
      Returns:
      an iterator over all terms.
    • variablesIterator

      Description copied from interface: AtomSet
      Returns an iterator over all variables in this atom set. Each term is iterated only once time.
      Specified by:
      variablesIterator in interface AtomSet
      Returns:
      an iterator over all variables.
    • constantsIterator

      Description copied from interface: AtomSet
      Returns an iterator over all constants in this atom set. Each term is iterated only once time.
      Specified by:
      constantsIterator in interface AtomSet
      Returns:
      an iterator over all constants.
    • literalsIterator

      Description copied from interface: AtomSet
      Returns an iterator over all literals in this atom set. Each term is iterated only once time.
      Specified by:
      literalsIterator in interface AtomSet
      Returns:
      an iterator over all literals.
    • getTerms

      @Deprecated Set<Term> getTerms(Term.Type type)
      Deprecated.
      Description copied from interface: AtomSet
      This method is deprecated since 1.3, use AtomSet.getVariables(), AtomSet.getConstants() or AtomSet.getLiterals() instead.

      Returns a Set of all terms of the specified type in this atom set.
      Specified by:
      getTerms in interface AtomSet
      Parameters:
      type - the term type to filter on
      Returns:
      a collection of all terms of the specified type in this atom set.
    • termsIterator

      Deprecated.
      Description copied from interface: AtomSet
      This method is deprecated since 1.3, use AtomSet.variablesIterator(), AtomSet.constantsIterator() or AtomSet.literalsIterator() instead.

      Returns an iterator of all terms of the specified type in this atom set. Each term is iterated only once time.
      Specified by:
      termsIterator in interface AtomSet
      Parameters:
      type - the term type to filter on
      Returns:
      an iterator of all terms.
    • iterator

      Description copied from interface: AtomSet
      Returns an iterator over the atoms in this atom set.
      Specified by:
      iterator in interface AtomSet
      Specified by:
      iterator in interface CloseableIterable<Atom>
      Specified by:
      iterator in interface CloseableIterableWithoutException<Atom>
      Specified by:
      iterator in interface Iterable<Atom>
      Returns:
      an iterator over the atoms in this atom set.
    • isSubSetOf

      @Deprecated boolean isSubSetOf(AtomSet atomset)
      Deprecated.
      Description copied from interface: AtomSet
      Use AtomSets.contains instead. Check if all atoms of this AtomSet are also contained in the specified AtomSet.
      Specified by:
      isSubSetOf in interface AtomSet
      Parameters:
      atomset - the candidate superset
      Returns:
      true if all atoms of this AtomSet are also contained in the specified atomset, false otherwise.
    • isEmpty

      boolean isEmpty()
      Description copied from interface: AtomSet
      Returns whether this atom set contains no atom.
      Specified by:
      isEmpty in interface AtomSet
      Returns:
      true if this atom set is empty, false otherwise.
    • add

      boolean add(Atom atom)
      Description copied from interface: AtomSet
      Add the specified atom to this atom set if is not already present.
      Specified by:
      add in interface AtomSet
      Parameters:
      atom - the atom to be added to this atom set
      Returns:
      true if this atom set did not already contain the specified atom
    • remove

      boolean remove(Atom atom)
      Description copied from interface: AtomSet
      Remove the specified atom from this this atom set.
      Specified by:
      remove in interface AtomSet
      Parameters:
      atom - the atom to be removed
      Returns:
      true if this atom set contained the specified atom.
    • removeWithoutCheck

      void removeWithoutCheck(Atom atom)
      Description copied from interface: AtomSet
      Remove the specified atom from this this atom set.
      Specified by:
      removeWithoutCheck in interface AtomSet
      Parameters:
      atom - the atom to be removed
    • clear

      void clear()
      Description copied from interface: AtomSet
      Removes all atoms from this atom set.
      Specified by:
      clear in interface AtomSet
    • toArray

      Atom[] toArray()
      Copies the atoms of this set into an array.
      Returns:
      the atoms contained in this set
    • removeAll

      boolean removeAll(CloseableIteratorWithoutException<? extends Atom> atoms)
      Removes all atoms provided by the specified iterator.
      Parameters:
      atoms - the atoms to remove
      Returns:
      true if this set changed as a result of the call
    • removeAll

      boolean removeAll(InMemoryAtomSet atoms)
      Removes all atoms contained in the specified atom set.
      Parameters:
      atoms - the atoms to remove
      Returns:
      true if this set changed as a result of the call
    • addAll

      boolean addAll(InMemoryAtomSet atoms)
      Adds all atoms from the specified in-memory atom set.
      Parameters:
      atoms - the atoms to add
      Returns:
      true if this set changed as a result of the call
    • addAll

      boolean addAll(CloseableIteratorWithoutException<? extends Atom> atoms)
      Adds all atoms produced by the specified iterator.
      Parameters:
      atoms - the atoms to add
      Returns:
      true if this set changed as a result of the call
    • size

      int size()
      Description copied from interface: AtomSet
      Returns the number of atoms in this set.
      Specified by:
      size in interface AtomSet
      Returns:
      the number of atoms in the set
    • spliterator

      default Spliterator<Atom> spliterator()
      Creates a Spliterator over the elements in this InMemoryAtomSet.

      The Spliterator reports Spliterator.DISTINCT. Implementations should document the reporting of additional characteristic values. The default implementation creates a late-binding spliterator from the InMemoryAtomSet's Iterator. The spliterator inherits the fail-fast properties of the InMemoryAtomSet's iterator.

      The created Spliterator additionally reports Spliterator.SIZED. The created Spliterator additionally reports Spliterator.SUBSIZED.

      Specified by:
      spliterator in interface Iterable<Atom>
      Returns:
      a Spliterator over the elements in this InMemoryAtomSet
    • stream

      default Stream<Atom> stream()
      Returns a sequential Stream with this InMemoryAtomSet as its source.

      This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.) The default implementation creates a sequential Stream from the InMemoryAtomSet Spliterator.

      Returns:
      a sequential Stream over the elements in this InMemoryAtomSet
    • parallelStream

      default Stream<Atom> parallelStream()
      Returns a possibly parallel Stream with this InMemoryAtomSet as its source. It is allowable for this method to return a sequential stream.

      This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.) The default implementation creates a parallel Stream from the InMemoryAtomSet Spliterator.

      Returns:
      a possibly parallel Stream over the elements in this InMemoryAtomSet