Package com.bayesserver
Class NetworkNodeCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Node>
-
- com.bayesserver.NetworkNodeCollection
-
public final class NetworkNodeCollection extends AbstractList<Node>
Represents the collection ofNetwork.getNodes()
maintained by theNetwork
class. Duplicates and null values are not allowed.
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Node item)
Inserts an element into the collection at the specified index.void
clear()
Removes all elements from the collection.boolean
contains(Object o)
Determines whether aNode
is in the collection.Node
get(int index)
Gets theNode
object at the specified index.Node
get(String name)
Performs a case sensitive lookup.Node
get(String name, boolean throwIfNotFound)
Performs a case sensitive lookup.Network
getNetwork()
TheNetwork
the collection belongs to.int
indexOf(Object o)
Determines the index of a specificNode
in the collection.Node
remove(int index)
Removes an element from the collection at the specified index, and any links that it has.boolean
remove(Node item)
Removes theNode
from the collection.Node
set(int index, Node value)
Sets theNode
object at the specified index.int
size()
-
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
-
get
public Node get(int index)
Gets theNode
object at the specified index.- Specified by:
get
in interfaceList<Node>
- Specified by:
get
in classAbstractList<Node>
- Parameters:
index
- The zero-based index of theNode
to find.- Returns:
- A
Node
. - Throws:
NullPointerException
- Raised when value being set is null.IllegalStateException
- Raised if the value being set already belongs to a network.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
set
public Node set(int index, Node value)
Sets theNode
object at the specified index.- Specified by:
set
in interfaceList<Node>
- Overrides:
set
in classAbstractList<Node>
- Parameters:
index
- The zero-based index of theNode
to find.- Returns:
- A
Node
. - Throws:
NullPointerException
- Raised when value being set is null.IllegalStateException
- Raised if the value being set already belongs to a network.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
contains
public boolean contains(Object o)
Determines whether aNode
is in the collection. The operation is O(1).- Specified by:
contains
in interfaceCollection<Node>
- Specified by:
contains
in interfaceList<Node>
- Overrides:
contains
in classAbstractCollection<Node>
- Parameters:
o
- TheNode
to locate in the collection. The value can be null.- Returns:
- true if [o] is found in the collection; otherwise, false.
-
clear
public void clear()
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<Node>
- Specified by:
clear
in interfaceList<Node>
- Overrides:
clear
in classAbstractList<Node>
-
add
public void add(int index, Node item)
Inserts an element into the collection at the specified index.- Specified by:
add
in interfaceList<Node>
- Overrides:
add
in classAbstractList<Node>
- 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 node already belongs to a network.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
indexOf
public int indexOf(Object o)
Determines the index of a specificNode
in the collection. This operation is O(1).
-
remove
public boolean remove(Node item)
Removes theNode
from the collection.- Parameters:
item
- TheNode
to be removed from the collection.- Returns:
- true if item was successfully removed from the collection; otherwise, false. This method also returns false if item is not found in the collection.
- Throws:
NullPointerException
- Raised if [item] is null.
-
remove
public Node remove(int index)
Removes an element from the collection at the specified index, and any links that it has.- Specified by:
remove
in interfaceList<Node>
- Overrides:
remove
in classAbstractList<Node>
- 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.
-
size
public int size()
- Specified by:
size
in interfaceCollection<Node>
- Specified by:
size
in interfaceList<Node>
- Specified by:
size
in classAbstractCollection<Node>
-
-