Package com.bayesserver
Class StateCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<State>
-
- com.bayesserver.StateCollection
-
public final class StateCollection extends AbstractList<State>
Represents a collection of states belonging to aVariable. Note that a continuous variable always has a single state.- See Also:
State
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, State item)Inserts an element into the collection at the specified index.voidclear()booleancontains(Object o)Determines whether aStateis in the collection.StatefindByValue(Object value)Finds the state whosevalue/> matches the given [value], or null if a match is not found.Stateget(int index)Gets theStateat the specified index.Stateget(String name)Performs a case sensitive lookup.Stateget(String name, boolean throwIfNotFound)Performs a case sensitive lookup.booleangetIsReadOnly()Gets a value indicating whether or not the collection is read-only.VariablegetVariable()Gets theVariablethis collection belongs to.intindexOf(Object o)Determines the index of a specificStatein the collection.Stateremove(int index)Removes an element from the collection at the specified index.Stateset(int index, State value)Sets theStateat the specified index.intsize()-
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
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, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
size
public int size()
- Specified by:
sizein interfaceCollection<State>- Specified by:
sizein interfaceList<State>- Specified by:
sizein classAbstractCollection<State>
-
getIsReadOnly
public boolean getIsReadOnly()
Gets a value indicating whether or not the collection is read-only. This will be true for continuous variables.
-
getVariable
public Variable getVariable()
Gets theVariablethis collection belongs to. This is null if this is a child state collection.- Returns:
- The variable that owns this collection.
-
findByValue
public State findByValue(Object value)
Finds the state whosevalue/> matches the given [value], or null if a match is not found. For discretized variables, eachState.getValue()is anInterval, and this method returns the state whose interval contains the given [value].- Parameters:
value- The value to match to aState.getValue().- Returns:
- The matching
Stateor null if a match is not found.
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<State>- Specified by:
clearin interfaceList<State>- Overrides:
clearin classAbstractList<State>
-
contains
public boolean contains(Object o)
Determines whether aStateis in the collection. The operation is O(1).- Specified by:
containsin interfaceCollection<State>- Specified by:
containsin interfaceList<State>- Overrides:
containsin classAbstractCollection<State>- Parameters:
o- TheStateto locate in the collection. The value can be null.- Returns:
- true if [o] is found in the collection; otherwise, false.
-
indexOf
public int indexOf(Object o)
Determines the index of a specificStatein the collection. This operation is O(1).
-
add
public void add(int index, State item)Inserts an element into the collection at the specified index.- Specified by:
addin interfaceList<State>- Overrides:
addin classAbstractList<State>- Parameters:
index- The zero based index at which to add the element.item- The item to insert. Cannot be null.- Throws:
NullPointerException- Raised when [item] is null.IllegalStateException- Raised if the state already belongs to a network.IllegalArgumentException- index is less than 0.-or-index is equal to or greater than the collection count.
-
remove
public State remove(int index)
Removes an element from the collection at the specified index.- Specified by:
removein interfaceList<State>- Overrides:
removein classAbstractList<State>- Parameters:
index- The zero based index at which to remove the element.- Throws:
IllegalArgumentException- index is less than 0.-or-index is equal to or greater than the collection count.
-
-