uk.org.redfelineninja.util
Class Adjacency

java.lang.Object
  |
  +--uk.org.redfelineninja.util.Adjacency

public class Adjacency
extends java.lang.Object

A data structure to store Adjanceny properties.

This data structure does not have strict safety contraints. Errors are passed the the programmer as exceptions from the underlying code so their interpretation must be with care.

Version:
0.5
Author:
Daniel Thompson, Sep 1998

Constructor Summary
Adjacency()
          Creates a new empty Adjancency matrix.
Adjacency(java.util.Vector v)
          Creates a new Adjancency matrix.
 
Method Summary
 void addElement(java.lang.Object o)
          Add another label to the data structure.
 boolean contains(java.lang.Object obj)
          Tests if the specifed object is a member of the Adjaceny matrix.
 void copyLabelsInto(java.lang.Object[] objs)
          Copies the labels of this matrix into an array.
 void doubleLink(java.lang.Object a, java.lang.Object b)
          Makes a two directional link between a and b
 void doubleUnlink(java.lang.Object a, java.lang.Object b)
          Ensures that there is no link in either direction between a and b
 java.util.Enumeration labels()
          Supplies an enumeration of all the labels used in this matrix.
 void link(java.lang.Object a, java.lang.Object b)
          Makes a link from a to b
 boolean linked(java.lang.Object a, java.lang.Object b)
          Tests for a link from a to b
 int size()
          Gives the size of this adjacency matrix.
 java.lang.String toString()
           
 void unlink(java.lang.Object a, java.lang.Object b)
          Ensures that there is no link from a to b
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Adjacency

public Adjacency()
Creates a new empty Adjancency matrix.


Adjacency

public Adjacency(java.util.Vector v)
Creates a new Adjancency matrix.

Parameters:
v - A vector to supply the headings
Method Detail

link

public void link(java.lang.Object a,
                 java.lang.Object b)
Makes a link from a to b

Parameters:
a - Source label
b - Dest. label

doubleLink

public void doubleLink(java.lang.Object a,
                       java.lang.Object b)
Makes a two directional link between a and b

Parameters:
a - label
b - label

unlink

public void unlink(java.lang.Object a,
                   java.lang.Object b)
Ensures that there is no link from a to b

Parameters:
a - Source label
b - Dest. label

doubleUnlink

public void doubleUnlink(java.lang.Object a,
                         java.lang.Object b)
Ensures that there is no link in either direction between a and b

Parameters:
a - label
b - label

linked

public boolean linked(java.lang.Object a,
                      java.lang.Object b)
Tests for a link from a to b

Parameters:
a - Source label
b - Dest. label

addElement

public void addElement(java.lang.Object o)
Add another label to the data structure. If required the data structure will resize itself.

Parameters:
o - Label to be added

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

contains

public boolean contains(java.lang.Object obj)
Tests if the specifed object is a member of the Adjaceny matrix.


size

public int size()
Gives the size of this adjacency matrix. Since the matrix must be square this is the length of one side.


labels

public java.util.Enumeration labels()
Supplies an enumeration of all the labels used in this matrix.


copyLabelsInto

public void copyLabelsInto(java.lang.Object[] objs)
Copies the labels of this matrix into an array. The array must be long enough to contain all the labels.