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:
java.lang.Iterable<T>
,java.util.Collection<T>
,BeliefBase
- Direct Known Subclasses:
ActionDescription
,ActionQuerySet
,ArgumentationKnowledgeBase
,ClBeliefSet
,CrMasBeliefSet
,DefeasibleLogicProgram
,DlBeliefSet
,DungTheory
,FolBeliefSet
,MarkovLogicNetwork
,MlBeliefSet
,PclBeliefSet
,PlBeliefSet
,RclBeliefSet
,RpclBeliefSet
,SimplePlLogicDeductiveKnowledgebase
public abstract class BeliefSet<T extends Formula,S extends Signature> extends java.lang.Object implements BeliefBase, java.util.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 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.private java.util.Set<T>
formulas
The set of formulas of this belief base.protected S
signature
The signature of this belief base.
-
Method Summary
Modifier and Type Method Description boolean
add(T f)
boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
boolean
equals(java.lang.Object obj)
S
getSignature()
Returns a copy of the signature that is attached to his belief base (it is always equal to or larger thanBeliefBase.getMinimalSignature()
).int
hashCode()
protected java.util.Set<T>
instantiateSet()
Instantiates the set which is used as data holder for the belief set.protected abstract S
instantiateSignature()
Instantiates the signature which is attached to the belief base.private S
instantiateSignature(S sig)
Instantiates the signature which is attached to the belief base as an instance of the class of the given signature.boolean
isEmpty()
java.util.Iterator<T>
iterator()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
void
setSignature(S sig)
Sets the signature that is attached to his belief base to a copy of the given signature.int
size()
java.lang.Object[]
toArray()
<R> R[]
toArray(R[] a)
java.lang.String
toString()
-
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
-
-
-
-
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(java.util.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 java.util.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
-
instantiateSignature
private S instantiateSignature(S sig)
Instantiates the signature which is attached to the belief base as an instance of the class of the given signature.- Parameters:
sig
- some signature- Returns:
- the signature which is attached to the belief base as an instance of the class of the given signature.
-
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 java.lang.IllegalArgumentException
Sets the signature that is attached to his belief base to a copy of the given signature.- Parameters:
sig
- a signature- Throws:
java.lang.IllegalArgumentException
- if the given signature is smaller in size than the belief base's formulas' signature.
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object obj)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<T> iterator()
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <R> R[] toArray(R[] a)
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceBeliefBase
- Overrides:
toString
in classjava.lang.Object
-
-