Package com.bayesserver
Class NetworkLinkCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Link>
-
- com.bayesserver.NetworkLinkCollection
-
public final class NetworkLinkCollection extends AbstractList<Link>
Represents the collection of directed links maintained by theNetwork
class. SeeNetwork.getLinks()
. Duplicates and null values are not allowed. This collection contains all links in a network. To find links specific to a particular node, seeLinksIn
andLinksOut
.- See Also:
Node.getLinksIn()
,Node.getLinksOut()
-
-
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, Link 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 aLink
is in the collection.Link
find(Node from, Node to)
Finds a link from one node to another if it exists, otherwise returns null.Link
find(Node from, Node to, int temporalOrder)
Finds a link from one node to another if it exists, otherwise returns null.Link
get(int index)
Gets theLink
object at the specified index.Network
getNetwork()
Gets theNetwork
the collection belongs to.int
indexOf(Object o)
Determines the index of a specificLink
in the collection.Link
remove(int index)
Removes an element from the collection at the specified index.boolean
remove(Link item)
Removes theLink
from the collection.Link
set(int index, Link value)
Sets theLink
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 Link get(int index)
Gets theLink
object at the specified index.- Specified by:
get
in interfaceList<Link>
- Specified by:
get
in classAbstractList<Link>
- Parameters:
index
- The zero-based index of theLink
to find.- Returns:
- A
Link
. - Throws:
NullPointerException
- Raised when value being set is null.IllegalStateException
- Raised if the value being set already belongs to a network, an equivalent link already exists, or the link nodes do not belong to theNetwork
.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
set
public Link set(int index, Link value)
Sets theLink
object at the specified index.- Specified by:
set
in interfaceList<Link>
- Overrides:
set
in classAbstractList<Link>
- Parameters:
index
- The zero-based index of theLink
to find.- Returns:
- A
Link
. - Throws:
NullPointerException
- Raised when value being set is null.IllegalStateException
- Raised if the value being set already belongs to a network, an equivalent link already exists, or the link nodes do not belong to theNetwork
.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
clear
public void clear()
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<Link>
- Specified by:
clear
in interfaceList<Link>
- Overrides:
clear
in classAbstractList<Link>
-
contains
public boolean contains(Object o)
Determines whether aLink
is in the collection. The operation is O(1).- Specified by:
contains
in interfaceCollection<Link>
- Specified by:
contains
in interfaceList<Link>
- Overrides:
contains
in classAbstractCollection<Link>
- Parameters:
o
- TheLink
to locate in the collection. The value can be null.- Returns:
- true if [o] is found in the collection; otherwise, false.
-
find
public Link find(Node from, Node to)
Finds a link from one node to another if it exists, otherwise returns null.- Parameters:
from
- The from (parent) node.to
- The to (child) node.- Returns:
- The link if found, otherwise null.
-
find
public Link find(Node from, Node to, int temporalOrder)
Finds a link from one node to another if it exists, otherwise returns null.- Parameters:
from
- The from (parent) node.to
- The to (child) node.temporalOrder
- The temporal order of the link. Will be null unless the nodes are temporal nodes.- Returns:
- The link if found, otherwise null.
-
indexOf
public int indexOf(Object o)
Determines the index of a specificLink
in the collection. This operation is O(1).
-
add
public void add(int index, Link item)
Inserts an element into the collection at the specified index.- Specified by:
add
in interfaceList<Link>
- Overrides:
add
in classAbstractList<Link>
- Parameters:
index
- The zero based index at which to add the element.item
- The item to insert. Cannot be null.- Throws:
NullPointerException
- Raised if [item] is null.IllegalStateException
- Raised if the new link already belongs to a network, an equivalent link already exists, or the link nodes do not belong to theNetwork
.IllegalArgumentException
- index is less than 0.-or-index is equal to or greater than the collection count.
-
remove
public boolean remove(Link item)
Removes theLink
from the collection.- Parameters:
item
- TheLink
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 Link remove(int index)
Removes an element from the collection at the specified index.- Specified by:
remove
in interfaceList<Link>
- Overrides:
remove
in classAbstractList<Link>
- 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<Link>
- Specified by:
size
in interfaceList<Link>
- Specified by:
size
in classAbstractCollection<Link>
-
-