Package net.sf.tweety.commons
Class BeliefSet<T extends Formula,S extends Signature>
- java.lang.Object
-
- net.sf.tweety.commons.BeliefSet<T,S>
-
- Type Parameters:
T- The type of the beliefs in this belief set.S- The type of signature attached to this belief set.
- All Implemented Interfaces:
Iterable<T>,Collection<T>,BeliefBase
public abstract class BeliefSet<T extends Formula,S extends Signature> extends Object implements BeliefBase, Collection<T>
This class models a belief set, i.e. a set of formulae of some formalism, and a signature.- Author:
- Matthias Thimm, Tim Janus, Anna Gessler
-
-
Field Summary
Fields Modifier and Type Field Description static booleanEQUALS_USES_SIGNATUREFlag that determines whetherObject.equals(Object)checks only for equality of the beliefs in the belief sets or whether it also checks for equality of the signatures attached to the belief sets.protected SsignatureThe signature of this belief base.
-
Method Summary
Modifier and Type Method Description booleanadd(T f)booleanaddAll(Collection<? extends T> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)booleanequals(Object obj)SgetSignature()Returns a copy of the signature that is attached to his belief base (it is always equal to or larger thanBeliefBase.getMinimalSignature()).inthashCode()protected Set<T>instantiateSet()Instantiates the set which is used as data holder for the belief set.protected abstract SinstantiateSignature()Instantiates the signature which is attached to the belief base.booleanisEmpty()Iterator<T>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)voidsetSignature(S sig)Sets the signature that is attached to his belief base to a copy of the given signature.intsize()Object[]toArray()<R> R[]toArray(R[] a)StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.tweety.commons.BeliefBase
getMinimalSignature
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
EQUALS_USES_SIGNATURE
public static final boolean EQUALS_USES_SIGNATURE
Flag that determines whetherObject.equals(Object)checks only for equality of the beliefs in the belief sets or whether it also checks for equality of the signatures attached to the belief sets.- See Also:
- Constant Field Values
-
signature
protected S extends Signature signature
The signature of this belief base. It is always larger than or equal toBeliefBase.getMinimalSignature()(the signature of the language offormulas).
-
-
Constructor Detail
-
BeliefSet
public BeliefSet()
Creates a new (empty) belief set.
-
BeliefSet
public BeliefSet(Collection<? extends T> c)
Creates a new belief set with the given collection of formulae.- Parameters:
c- a collection of formulae.
-
BeliefSet
public BeliefSet(S sig)
Creates a new belief set with the given type of signature.- Parameters:
sig- a signature
-
-
Method Detail
-
instantiateSet
protected Set<T> instantiateSet()
Instantiates the set which is used as data holder for the belief set. Subclasses might override this method if the do not want to use HashSet as container implementation- Returns:
- an new set
-
instantiateSignature
protected abstract S instantiateSignature()
Instantiates the signature which is attached to the belief base.- Returns:
- the signature of this belief base
-
getSignature
public S getSignature()
Returns a copy of the signature that is attached to his belief base (it is always equal to or larger thanBeliefBase.getMinimalSignature()).- Returns:
- the signature of this knowledge base.
-
setSignature
public void setSignature(S sig) throws IllegalArgumentException
Sets the signature that is attached to his belief base to a copy of the given signature.- Parameters:
sig- a signature- Throws:
IllegalArgumentException- if the given signature is smaller in size than the belief base's formulas' signature.
-
add
public boolean add(T f)
- Specified by:
addin interfaceCollection<T extends Formula>
-
addAll
public boolean addAll(Collection<? extends T> c)
- Specified by:
addAllin interfaceCollection<T extends Formula>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<T extends Formula>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<T extends Formula>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T extends Formula>
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T extends Formula>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<T extends Formula>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<T extends Formula>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T extends Formula>
-
size
public int size()
- Specified by:
sizein interfaceCollection<T extends Formula>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T extends Formula>
-
toArray
public <R> R[] toArray(R[] a)
- Specified by:
toArrayin interfaceCollection<T extends Formula>
-
toString
public String toString()
- Specified by:
toStringin interfaceBeliefBase- Overrides:
toStringin classObject
-
-