jcreek.cke.graph
Class VertexList

java.lang.Object
  extended byjcreek.cke.graph.VertexList
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class VertexList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A VertexList encapsulates a list of vertices. It can hold as many vertices as needed.

Version:
1.0 5/5/97
Author:
Nathan Fiedler
See Also:
Vector, Serialized Form

Field Summary
protected  java.util.Vector vertices
          List of vertices.
 
Constructor Summary
VertexList()
          No-arg constructor; creates the vector to hold the list of vertices.
VertexList(VisualEntity[] veList)
          creates the vector to hold the list of vertices.
 
Method Summary
 void add(VisualEntity node)
          Add a new VisualEntity to this list.
 void clear()
          Removes all of the vertices from the list.
 java.lang.Object clone()
          Creates a shallow copy of this VisualEntity list, cloning the list of the vertices into the new object.
 VertexList copy()
          Makes a deep copy of this vertex list, cloning each of the vertices in the list.
 VisualEntity get(int index)
          Get the VisualEntity stored at the specified index in the list.
 int indexOf(VisualEntity node)
          Find the index of the element in the list.
 void join(VertexList list)
          Combines the elements from list into this list of vertices.
 boolean remove(int nodeToRemove)
          Removes the specified element from the list given the index of the VisualEntity within the list.
 boolean remove(VisualEntity nodeToRemove)
          Removes the specified element from the list given the VisualEntity itself.
 int size()
          Returns the size of the vertex list.
 boolean verify()
          Error-checking method that verifies the data and structure of the vertex list object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vertices

protected java.util.Vector vertices
List of vertices.

Constructor Detail

VertexList

public VertexList()
No-arg constructor; creates the vector to hold the list of vertices.


VertexList

public VertexList(VisualEntity[] veList)
creates the vector to hold the list of vertices.

Method Detail

add

public void add(VisualEntity node)
Add a new VisualEntity to this list. Won't add null references.

Parameters:
node - new VisualEntity to add to list

clear

public void clear()
Removes all of the vertices from the list.


clone

public java.lang.Object clone()
Creates a shallow copy of this VisualEntity list, cloning the list of the vertices into the new object.

Returns:
clone of this vertex list

copy

public VertexList copy()
Makes a deep copy of this vertex list, cloning each of the vertices in the list.

Returns:
copy of this vertex list

get

public VisualEntity get(int index)
Get the VisualEntity stored at the specified index in the list.

Parameters:
index - number of the nth VisualEntity to get (0-based)
Returns:
the VisualEntity specified, or null if not in list

indexOf

public int indexOf(VisualEntity node)
Find the index of the element in the list.

Parameters:
node - VisualEntity to search for
Returns:
position of element in list; -1 if not found

join

public void join(VertexList list)
Combines the elements from list into this list of vertices. Vertices in list will only be added if there is nothing similar in our list.

Parameters:
list - list of vertices to add

remove

public boolean remove(VisualEntity nodeToRemove)
Removes the specified element from the list given the VisualEntity itself.

Parameters:
nodeToRemove - VisualEntity to remove from list
Returns:
true if the VisualEntity was in the list, false otherwise

remove

public boolean remove(int nodeToRemove)
Removes the specified element from the list given the index of the VisualEntity within the list.

Parameters:
nodeToRemove - index of VisualEntity to remove from list
Returns:
true if the VisualEntity was in the list, false otherwise

size

public int size()
Returns the size of the vertex list.

Returns:
number of vertices in list

verify

public boolean verify()
Error-checking method that verifies the data and structure of the vertex list object.

Returns:
true if okay, false if error


Created at IDI, NTNU by the Artificial Intelligence and Learning group