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 theNetworkclass. 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, seeLinksInandLinksOut.- 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 voidadd(int index, Link item)Inserts an element into the collection at the specified index.voidclear()Removes all elements from the collection.booleancontains(Object o)Determines whether aLinkis in the collection.Linkfind(Node from, Node to)Finds a link from one node to another if it exists, otherwise returns null.Linkfind(Node from, Node to, int temporalOrder)Finds a link from one node to another if it exists, otherwise returns null.Linkget(int index)Gets theLinkobject at the specified index.NetworkgetNetwork()Gets theNetworkthe collection belongs to.intindexOf(Object o)Determines the index of a specificLinkin the collection.Linkremove(int index)Removes an element from the collection at the specified index.booleanremove(Link item)Removes theLinkfrom the collection.Linkset(int index, Link value)Sets theLinkobject at 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
-
get
public Link get(int index)
Gets theLinkobject at the specified index.- Specified by:
getin interfaceList<Link>- Specified by:
getin classAbstractList<Link>- Parameters:
index- The zero-based index of theLinkto 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 theLinkobject at the specified index.- Specified by:
setin interfaceList<Link>- Overrides:
setin classAbstractList<Link>- Parameters:
index- The zero-based index of theLinkto 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:
clearin interfaceCollection<Link>- Specified by:
clearin interfaceList<Link>- Overrides:
clearin classAbstractList<Link>
-
contains
public boolean contains(Object o)
Determines whether aLinkis in the collection. The operation is O(1).- Specified by:
containsin interfaceCollection<Link>- Specified by:
containsin interfaceList<Link>- Overrides:
containsin classAbstractCollection<Link>- Parameters:
o- TheLinkto 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 specificLinkin 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:
addin interfaceList<Link>- Overrides:
addin 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 theLinkfrom the collection.- Parameters:
item- TheLinkto 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:
removein interfaceList<Link>- Overrides:
removein 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:
sizein interfaceCollection<Link>- Specified by:
sizein interfaceList<Link>- Specified by:
sizein classAbstractCollection<Link>
-
-