norsys.netica
Class NodeList

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--norsys.netica.NodeList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class NodeList
extends java.util.Vector

A java.util.Vector that is meant to store only Nodes from a single Net. If other objects are inserted, or Nodes from different Nets are inserted, an exception will be thrown when the NodeList is passed to Netica.

Since:
All versions
Version:
5.04 - January 21, 2012
See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
NodeList(Net parentNet)

Constructs an empty NodeList of initial capacity 100.

NodeList(NodeList nodeList)

Copy constructs a new NodeList from an existing NodeList.

 
Method Summary
 Net getNet()

Returns the Net that this NodeList's nodes come from.

 Node getNode(int index)

A convenience version of java.util.Vector.get(int), that returns a Node, rather than an Object, to save you from having to do the cast yourself.

static int[] mapStateList(int[] srcStates, NodeList srcNodes, NodeList destNodes)

Returns an array of states, the same states that are in the srcStates array, except in a different order.

 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

public NodeList (
 Net  parentNet 
) throws NeticaException
Constructs an empty NodeList of initial capacity 100.

Only Node objects that come from parentNet should be added to this list.

Parameters:
Net    parentNet    The net from whose nodes this nodeList will be assembled.

Version:

Versions 2.20 and greater have this method.

public NodeList (
 NodeList  nodeList 
) throws NeticaException
Copy constructs a new NodeList from an existing NodeList.

Performs a "shallow copy" in the sense that new Node objects are not constructed.

Only Node objects that are from the same net as nodeList should be added to this list.

Parameters:
NodeList    nodeList    The nodelist to copy.

Version:

Versions 2.12 and greater have this method.
Method Detail
public Net getNet ( )
Returns the Net that this NodeList's nodes come from.

Version:
This method is available in all versions.

public Node getNode (
 int  index 
) throws ArrayIndexOutOfBoundsException
A convenience version of java.util.Vector.get(int), that returns a Node, rather than an Object, to save you from having to do the cast yourself. Throws ArrayIndexOutOfBoundsException, if index is out of range.

Parameters:
int    index    the index to the i'th member of the list, beginning from 0.

Version:
Versions 2.12 and later have this method.
Example:
  Node node = nodelist.getNode(2); //get the 3rd element of nodelist

public static int[ ] mapStateList (
 int[ ]  srcStates
 NodeList  srcNodes
 NodeList  destNodes 
) throws NeticaException
Returns an array of states, the same states that are in the srcStates array, except in a different order.

The order of srcStates is given by srcNodes, and the order of the returned states will be given by destNodes.

srcNodes may not contain duplicates, but destNodes may (the state values will be duplicated accordingly). Any srcStates entries for nodes in srcNodes which don't appear in destNodes will be ignored. If there are nodes in destNodes that don't appear in srcNodes, then EVERY_STATE will be placed in the corresponding position of the returned array.

The idea is that each entry of srcStates contains a value of the corresponding node in srcNodes, and now we want these values in the order given by destNodes.

Parameters:
int[]    srcStates    an array of states, one element per member of srcNodes
NodeList    srcNodes    a list of nodes in the same order as the states in srcStates
NodeList    destNodes    a list of the exact same nodes as in srcNodes, but in a different order, the order you want the returned state array to be in

Version:

Versions 1.18 and later have this method.
In the C Version of the API, this function is named MapStateList_bn.
See Also:
setCPTable    Requires a list of states in the correct order
getStateFuncTable    Also requires correctly ordered states
getParents    For the above, the list of states must in parent order
getFinding    Determine the current state finding of a node
Caseset    For sets of node-value pairs
reorderStates    For the states within a single node