Class DefaultInMemoryAtomSet
- All Implemented Interfaces:
AtomSet, InMemoryAtomSet, CloseableIterable<Atom>, CloseableIterableWithoutException<Atom>, Iterable<Atom>
- Author:
- Guillaume Pérution-Kihli
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor By default, we use a HashSet of AtomDefaultInMemoryAtomSet(Atom... atoms) Creates an atom set containing the provided atoms.DefaultInMemoryAtomSet(AtomSet atomset) Construct the atom set with the elements contained in the AtomSet in parameterDefaultInMemoryAtomSet(InMemoryAtomSet atomset) Construct the atom set with the elements contained in the AtomSet in parameterConstruct the atom set with the elements contained in the iterator in parameterConstruct the atom set with the elements contained in the iterator in parameterDefaultInMemoryAtomSet(Collection<Atom> collection) A copy constructor that can copy any Collection of AtomDefaultInMemoryAtomSet(Set<Atom> javaAtomSet) This constructor allows you to use any Collection that implements the Set of Atom interface -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd the specified atom to this atom set if is not already present.Returns an iterator over all atoms with the specified predicate.voidclear()Removes all atoms from this atom set.Returns the fresh symbol generator associated with this atom set.Returns a Set of all predicates in this atom set.getTerms()Returns a Set of all terms in this atom set.booleanisEmpty()Returns whether this atom set contains no atom.iterator()Returns an iterator over the atoms in this atom set.match(Atom atom, Substitution s) Returns an iterator over atoms that match predicate and constants from the specified atom.Returns a possibly parallelStreamwith this InMemoryAtomSet as its source.Returns an iterator over all predicates in this atom set.booleanRemove the specified atom from this this atom set.voidremoveWithoutCheck(Atom atom) Remove the specified atom from this this atom set.intsize()This default implementation should be overriden, it is convenient for in memory set, but will be inefficient in some case.Creates aSpliteratorover the elements in this InMemoryAtomSet.stream()Returns a sequentialStreamwith this InMemoryAtomSet as its source.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.Methods inherited from class AbstractInMemoryAtomSet
addAll, addAll, constantsIterator, contains, getConstants, getLiterals, getTerms, getVariables, isSubSetOf, literalsIterator, match, removeAll, removeAll, toArray, variablesIteratorMethods inherited from class AbstractAtomSet
addAll, addAll, equals, equals, removeAll, removeAll, toStringMethods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface AtomSet
addAll, addAll, atomsByTerm, containsTerm, removeAll, removeAll
-
Constructor Details
-
DefaultInMemoryAtomSet
public DefaultInMemoryAtomSet()Default constructor By default, we use a HashSet of Atom -
DefaultInMemoryAtomSet
-
DefaultInMemoryAtomSet
A copy constructor that can copy any Collection of Atom- Parameters:
collection- the atoms to copy into the set
-
DefaultInMemoryAtomSet
Creates an atom set containing the provided atoms.- Parameters:
atoms- the atoms to add to the set
-
DefaultInMemoryAtomSet
Construct the atom set with the elements contained in the iterator in parameter- Parameters:
it- The elements to add- Throws:
IteratorException- if the iterator cannot be fully consumed
-
DefaultInMemoryAtomSet
Construct the atom set with the elements contained in the iterator in parameter- Parameters:
it- The elements to add
-
DefaultInMemoryAtomSet
Construct the atom set with the elements contained in the AtomSet in parameter- Parameters:
atomset- the elements to add- Throws:
IteratorException- if the atom set iterator cannot be fully consumed
-
DefaultInMemoryAtomSet
Construct the atom set with the elements contained in the AtomSet in parameter- Parameters:
atomset- the elements to add
-
-
Method Details
-
match
Description copied from interface:AtomSetReturns 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.
-
atomsByPredicate
Description copied from interface:AtomSetReturns an iterator over all atoms with the specified predicate.- Parameters:
p- the predicate to search for- Returns:
- an iterator over all atoms with the specified predicate.
-
termsByPredicatePosition
Description copied from interface:AtomSetReturns 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.
-
predicatesIterator
Description copied from interface:AtomSetReturns an iterator over all predicates in this atom set. Each predicate is iterated only once time.- Returns:
- an iterator over all predicates.
-
termsIterator
Description copied from interface:AtomSetReturns an iterator over all terms in this atom set. Each term is iterated only once time.- Returns:
- an iterator over all terms.
-
termsIterator
Deprecated.Description copied from interface:AtomSetThis method is deprecated since 1.3, useAtomSet.variablesIterator(),AtomSet.constantsIterator()orAtomSet.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.
-
iterator
Description copied from interface:AtomSetReturns an iterator over the atoms in this atom set.- Returns:
- an iterator over the atoms in this atom set.
-
add
-
removeWithoutCheck
-
remove
Description copied from interface:AtomSetRemove the specified atom from this this atom set.- Specified by:
removein interfaceAtomSet- Specified by:
removein interfaceInMemoryAtomSet- Overrides:
removein classAbstractInMemoryAtomSet- Parameters:
atom- the atom to be removed- Returns:
- true if this atom set contained the specified atom.
-
clear
public void clear()Description copied from interface:AtomSetRemoves all atoms from this atom set. -
getFreshSymbolGenerator
Description copied from interface:AtomSetReturns the fresh symbol generator associated with this atom set.- Returns:
- the symbol generator used by this atom set
-
size
public int size()Description copied from class:AbstractAtomSetThis default implementation should be overriden, it is convenient for in memory set, but will be inefficient in some case.- Specified by:
sizein interfaceAtomSet- Specified by:
sizein interfaceInMemoryAtomSet- Overrides:
sizein classAbstractInMemoryAtomSet- Returns:
- the number of atoms in the set
- See Also:
-
isEmpty
public boolean isEmpty()Description copied from interface:AtomSetReturns whether this atom set contains no atom.- Specified by:
isEmptyin interfaceAtomSet- Specified by:
isEmptyin interfaceInMemoryAtomSet- Overrides:
isEmptyin classAbstractInMemoryAtomSet- Returns:
- true if this atom set is empty, false otherwise.
-
getTerms
Description copied from interface:AtomSetReturns a Set of all terms in this atom set.- Specified by:
getTermsin interfaceAtomSet- Specified by:
getTermsin interfaceInMemoryAtomSet- Overrides:
getTermsin classAbstractInMemoryAtomSet- Returns:
- a Set of all terms.
-
getPredicates
Description copied from interface:AtomSetReturns a Set of all predicates in this atom set.- Specified by:
getPredicatesin interfaceAtomSet- Specified by:
getPredicatesin interfaceInMemoryAtomSet- Overrides:
getPredicatesin classAbstractInMemoryAtomSet- Returns:
- a Set of all predicates.
-
spliterator
Description copied from interface:InMemoryAtomSetCreates aSpliteratorover the elements in this InMemoryAtomSet.The
SpliteratorreportsSpliterator.DISTINCT. Implementations should document the reporting of additional characteristic values. The default implementation creates a late-binding spliterator from the InMemoryAtomSet'sIterator. The spliterator inherits the fail-fast properties of the InMemoryAtomSet's iterator.The created
Spliteratoradditionally reportsSpliterator.SIZED. The createdSpliteratoradditionally reportsSpliterator.SUBSIZED.- Returns:
- a
Spliteratorover the elements in this InMemoryAtomSet
-
stream
Description copied from interface:InMemoryAtomSetReturns a sequentialStreamwith this InMemoryAtomSet as its source.This method should be overridden when the
InMemoryAtomSet.spliterator()method cannot return a spliterator that isIMMUTABLE,CONCURRENT, or late-binding. (SeeInMemoryAtomSet.spliterator()for details.) The default implementation creates a sequentialStreamfrom the InMemoryAtomSetSpliterator.- Returns:
- a sequential
Streamover the elements in this InMemoryAtomSet
-
parallelStream
Description copied from interface:InMemoryAtomSetReturns a possibly parallelStreamwith this InMemoryAtomSet as its source. It is allowable for this method to return a sequential stream.This method should be overridden when the
InMemoryAtomSet.spliterator()method cannot return a spliterator that isIMMUTABLE,CONCURRENT, or late-binding. (SeeInMemoryAtomSet.spliterator()for details.) The default implementation creates a parallelStreamfrom the InMemoryAtomSetSpliterator.- Returns:
- a possibly parallel
Streamover the elements in this InMemoryAtomSet
-