jcreek.cke.graph
Class RelationList

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

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

See Also:
Serialized Form

Field Summary
protected  java.util.Vector relations
          List of vertices.
 
Constructor Summary
RelationList()
          No-arg constructor; creates the vector to hold the list of vertices.
RelationList(VisualRelation[] relList)
          creates the vector to hold the list of relations.
 
Method Summary
 void add(VisualRelation edge)
          Add a new VisualRelation to this list.
 void clear()
          Removes all of the relations from the list.
 java.lang.Object clone()
          Creates a shallow copy of this VisualRelation list, cloning the list of the relations into the new object.
 RelationList copy()
          Makes a deep copy of this relation list, cloning each of the vertices in the list.
 RelationList find(VisualEntity v)
          Returns all the edges that are connected to the given vertex.
 VisualRelation get(int index)
          Get the VisualRelation stored at the specified index in the list.
 int indexOf(VisualRelation edge)
          Find the index of the element in the list.
 void join(RelationList list)
          Combines the elements from list into this list of relations.
 boolean remove(int edgeToRemove)
          Removes the specified element from the list given the index of the VisualRelation within the list.
 boolean remove(VisualRelation edgeToRemove)
          Removes the specified element from the list given the VisualRelation itself.
 int size()
          Returns the size of the relation 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

relations

protected java.util.Vector relations
List of vertices.

Constructor Detail

RelationList

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


RelationList

public RelationList(VisualRelation[] relList)
creates the vector to hold the list of relations.

Method Detail

add

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


clear

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


clone

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

Returns:
clone of this relation list

copy

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

Returns:
copy of this relation list

get

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

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

indexOf

public int indexOf(VisualRelation edge)
Find the index of the element in the list.

Returns:
position of element in list; -1 if not found

join

public void join(RelationList list)
Combines the elements from list into this list of relations. Relations 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(VisualRelation edgeToRemove)
Removes the specified element from the list given the VisualRelation itself.

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

remove

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

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

find

public RelationList find(VisualEntity v)
Returns all the edges that are connected to the given vertex. Useful when removing a vertex from the graph.

Parameters:
v - vertex to find edges for
Returns:
list of edges connected to vertex; null if no match

size

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

Returns:
number of relations 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