Interface AtomSet
- All Superinterfaces:
CloseableIterable<Atom>
- All Known Subinterfaces:
InMemoryAtomSet
- All Known Implementing Classes:
AbstractAtomSet, AbstractImmutableAtomSet, AbstractInMemoryAtomSet, DefaultInMemoryAtomSet, LinkedListAtomSet
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 Summary
Modifier and TypeMethodDescriptionbooleanAdd the specified atom to this atom set if is not already present.booleanAdds all atoms from the specified atom set.booleanaddAll(CloseableIterator<? extends Atom> atoms) Add the specified atom stream to this atom set.atomsByPredicate(Predicate predicate) Returns an iterator over all atoms with the specified predicate.default CloseableIterator<Atom> atomsByTerm(Term term) Returns an iterator over all atoms which contain specified term.voidclear()Removes all atoms from this atom set.Returns an iterator over all constants in this atom set.booleanReturns true if this atom set contains the specified atom.default booleancontainsTerm(Term t) Check if there exists an atom that contains the term tReturns a Set of all constants in this atom set.Returns the fresh symbol generator associated with this atom set.Returns a Set of all literals in this atom set.Returns a Set of all predicates in this atom set.getTerms()Returns a Set of all terms in this atom set.Deprecated.Returns a Set of all variables in this atom set.booleanisEmpty()Returns whether this atom set contains no atom.booleanisSubSetOf(AtomSet atomset) Deprecated.iterator()Returns an iterator over the atoms in this atom set.Returns an iterator over all literals in this atom set.Returns an iterator over atoms that match predicate and constants from the specified atom.match(Atom atom, Substitution s) Returns an iterator over atoms that match predicate and constants from the specified atom.Returns an iterator over all predicates in this atom set.booleanRemove the specified atom from this this atom set.booleanRemoves all atoms contained in the specified atom set.booleanremoveAll(CloseableIterator<? extends Atom> atoms) Remove the specified atom stream from this atom set.default voidremoveWithoutCheck(Atom atom) Remove the specified atom from this this atom set.intsize()Returns the number of atoms in this set.termsByPredicatePosition(Predicate p, int position) Returns an iterator over terms which are in a specific position in at least one atom with the specified predicate.Returns an iterator over all terms in this atom set.termsIterator(Term.Type type) Deprecated.Returns an iterator over all variables in this atom set.
-
Method Details
-
contains
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 matchs- 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
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
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
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 inspectposition- 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
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
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
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
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
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
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.This method is deprecated since 1.3, usegetVariables(),getConstants()orgetLiterals()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
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
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
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
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, usevariablesIterator(),constantsIterator()orliteralsIterator()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.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
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
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
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
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
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
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
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
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
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
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:
iteratorin interfaceCloseableIterable<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
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
-