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 stores Nodes from a single Net only.

Since:
2.08
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(int length, Net parentNet)
          Copy constructs a new Nodelist from an existing Nodelist.
NodeList(NodeList nodes)
          Construct a new (empty) list of nodes.
 
Method Summary
 void add(int index, java.lang.Object obj)
          Overrides java.util.Vector.add(); prevents the adding of any object other than Nodesfrom our defining Net.
 boolean add(java.lang.Object obj)
          Overrides java.util.Vector.add(); prevents the adding of any object other than Nodes from our defining Net.
 void addElement(java.lang.Object obj)
          Overrides java.util.Vector.add(); prevents the adding of any object other than Nodes from our defining Net.
 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
addAll, addAll, 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

NodeList

public NodeList(int length,
                Net parentNet)
         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.

Version:

Versions 2.12 and greater have this function.
Parameters:
nodes - The nodelist to copy.

NodeList

public NodeList(NodeList nodes)
         throws NeticaException
Construct a new (empty) list of nodes.



Version:

This function is available in all versions.
In the C Version of the API, this function is called NewNodeList_bn.
Parameters:
length - The initial capacity.
net - The net from whose nodes this nodeList will be assembled.
Method Detail

getNet

public Net getNet()
Returns the Net that this NodeList's nodes come from.

Version:
This function is available in all versions.

add

public boolean add(java.lang.Object obj)
Overrides java.util.Vector.add(); prevents the adding of any object other than Nodes from our defining Net. If an attempt is made anything else, then it returns false and ignores the request.

Version:
This function is available in all versions.
Overrides:
add in class java.util.Vector
Parameters:
obj - Any Object, though onlyNodes from our defining Net will be added.

add

public void add(int index,
                java.lang.Object obj)
Overrides java.util.Vector.add(); prevents the adding of any object other than Nodesfrom our defining Net. If an attempt is made anything else, then the request is ignored.

Version:
This function is available in all versions.
Overrides:
add in class java.util.Vector
Parameters:
index - The position in the vector, starting from 0, where to add the object.
obj - Any Object, though onlyNodes from our defining Net will be added.

addElement

public void addElement(java.lang.Object obj)
Overrides java.util.Vector.add(); prevents the adding of any object other than Nodes from our defining Net. If an attempt is made anything else, then the request is ignored.

Version:
This function is available in all versions.
Overrides:
addElement in class java.util.Vector
Parameters:
obj - Any Object, though onlyNodes from our defining Net will be added.

mapStateList

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.

destNodes must contain exactly the same nodes as srcNodes, but possibly in a different order.

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.

Version:

Versions 1.18 and later have this function.
In the C Version of the API, this function is called MapStateList_bn.
Parameters:
srcStates - an array of states, one element per member of srcNodes
srcNodes - a list of nodes in the same order as the states in srcStates
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

getNode

public Node getNode(int index)
             throws java.lang.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 [0..size()].

Version:
Versions 2.12 and later have this function.
Example:
  Node node = nodelist.getNode(2); //get the 3rd element of nodelist
Parameters:
index - the index to the i'th member of the list, beginning from 0.