Package com.bayesserver
Class VariableContextCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<VariableContext>
-
- com.bayesserver.VariableContextCollection
-
- All Implemented Interfaces:
Iterable<VariableContext>
,Collection<VariableContext>
,List<VariableContext>
public final class VariableContextCollection extends AbstractList<VariableContext>
Represents a read-only collection of variables. Each variable in the collection may have an associated time if the Bayesian network is a Dynamic Bayesian network (DBN). A variable can only appear more than once in the collection if it has different times associated. All variables are marked as either head or tail. Head variables are those on the left, and tail variables are those on the right in the expression P(A|B).
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Variable variable)
Determines whether aVariable
is in the collection.boolean
contains(VariableContext variableContext, boolean ignoreHeadTail)
Determines whether a variable-time (and optionally Head/Tail) combination is contained in the collection.boolean
contains(Variable variable, Integer time)
Determines whether aVariable
is in the collection at the specified [time].boolean
containsAll(VariableContextCollection items, boolean ignoreHeadTail)
Determines whether all [items] are matched in the collection.boolean
containsAll(List<Variable> items)
Determines whether all [items] are matched in the collection.boolean
containsAll(List<Variable> items, List<Integer> times)
Determines whether all [items] are matched in the collection.boolean
containsAll(List<VariableContext> items, boolean ignoreHeadTail)
Determines whether all [items] are matched in the collection at the specified times.boolean
containsAny(VariableContextCollection items, boolean ignoreHeadTail)
Determines whether any [items] are matched in the collection.boolean
containsAny(List<Variable> items, List<Integer> times)
Determines whether any [items] are matched in the collection.VariableContext
get(int index)
Gets theVariable
object at the specified index.int
indexOf(Variable item)
Determines the index of a specificVariable
in the collection.int
indexOf(VariableContext variableContext, boolean ignoreHeadTail)
Determines the index of a specific variable-time combination in the collection.int
indexOf(Variable variable, Integer time)
Determines the index of a specificVariable
in the collection at the specified [time].VariableContext
set(int index, VariableContext value)
Gets theVariable
object at the specified index.int
size()
Gets the number of elements contained in the collection.String
toString()
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<VariableContext>
- Returns:
- A
String
that represents the currentObject
.
-
size
public int size()
Gets the number of elements contained in the collection.- Specified by:
size
in interfaceCollection<VariableContext>
- Specified by:
size
in interfaceList<VariableContext>
- Specified by:
size
in classAbstractCollection<VariableContext>
-
indexOf
public int indexOf(Variable item)
Determines the index of a specificVariable
in the collection.- Parameters:
item
- The variable to find. The value can be null.- Returns:
- The index of the variable or -1 if not found.
-
indexOf
public int indexOf(VariableContext variableContext, boolean ignoreHeadTail)
Determines the index of a specific variable-time combination in the collection.- Parameters:
variableContext
- The variable context to match.ignoreHeadTail
- When true, the Head and Tail specifications need not match.- Returns:
- The index of the variable or -1 if not found.
-
indexOf
public int indexOf(Variable variable, Integer time)
Determines the index of a specificVariable
in the collection at the specified [time].- Parameters:
variable
- The variable to find.time
- The variable time. Can be null for non temporal variables.- Returns:
- The index of the variable or -1 if not found.
-
contains
public boolean contains(Variable variable)
Determines whether aVariable
is in the collection.- Parameters:
variable
- TheVariable
to locate in the collection. The value can be null.- Returns:
- true if [variable] is found in the collection; otherwise, false.
-
contains
public boolean contains(VariableContext variableContext, boolean ignoreHeadTail)
Determines whether a variable-time (and optionally Head/Tail) combination is contained in the collection.- Parameters:
variableContext
- The variableContext to match.ignoreHeadTail
- When true, the Head and Tail specifications need not match.- Returns:
- True if a match is found; false otherwise.
-
contains
public boolean contains(Variable variable, Integer time)
Determines whether aVariable
is in the collection at the specified [time].- Parameters:
variable
- TheVariable
to locate in the collection. The value can be null.time
- The time associated with the variable, if any. Can be null.- Returns:
- true if [variable] is found in the collection; otherwise, false.
-
containsAll
public boolean containsAll(List<Variable> items)
Determines whether all [items] are matched in the collection.- Parameters:
items
- The items to locate in the collection. Cannot be null.- Returns:
- true if all items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
containsAll
public boolean containsAll(List<Variable> items, List<Integer> times)
Determines whether all [items] are matched in the collection.- Parameters:
items
- The items to locate in the collection. Cannot be null.times
- The times associated with [items]. Can be null.- Returns:
- true if all items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
containsAll
public boolean containsAll(List<VariableContext> items, boolean ignoreHeadTail)
Determines whether all [items] are matched in the collection at the specified times.- Parameters:
items
- The items to locate in the collection. Cannot be null.ignoreHeadTail
- When true, head and tail specifications need not match.- Returns:
- true if all items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
containsAll
public boolean containsAll(VariableContextCollection items, boolean ignoreHeadTail)
Determines whether all [items] are matched in the collection.- Parameters:
items
- The items to locate in the collection. Cannot be null.ignoreHeadTail
- When true, the Head and Tail specifications need not match.- Returns:
- true if all items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
containsAny
public boolean containsAny(VariableContextCollection items, boolean ignoreHeadTail)
Determines whether any [items] are matched in the collection.- Parameters:
items
- The items to locate in the collection. Cannot be null.ignoreHeadTail
- When true, the Head and Tail specifications need not match.- Returns:
- true if any items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
containsAny
public boolean containsAny(List<Variable> items, List<Integer> times)
Determines whether any [items] are matched in the collection.- Parameters:
items
- The items to locate in the collection. Cannot be null.times
- The time for each variable. Each time can be null for non temporal variables. [times] can be null.- Returns:
- true if any items were matched in the collection; otherwise, false.
- Throws:
NullPointerException
- Raised when [items] is null.
-
get
public VariableContext get(int index)
Gets theVariable
object at the specified index.- Specified by:
get
in interfaceList<VariableContext>
- Specified by:
get
in classAbstractList<VariableContext>
- Parameters:
index
- The zero-based index of theVariable
to find.- Returns:
- A
Variable
.
-
set
public VariableContext set(int index, VariableContext value)
Gets theVariable
object at the specified index.- Specified by:
set
in interfaceList<VariableContext>
- Overrides:
set
in classAbstractList<VariableContext>
- Parameters:
index
- The zero-based index of theVariable
to find.- Returns:
- A
Variable
.
-
-