graph
Class StoredVertex

java.lang.Object
  |
  +--container.HashDecorable
        |
        +--graph.StoredVertex
All Implemented Interfaces:
Decorable, Position, Vertex
Direct Known Subclasses:
DirectedAdjListVertex

public class StoredVertex
extends HashDecorable
implements Vertex

A straightforward implementation of the Vertex interface. Other implementations are possible. This class may be extended. For example, in an adjacency-list implementation of a graph, each vertex must also store its incident edges.


Field Summary
(package private)  java.lang.Object element
          Element stored at this vertex.
 
Fields inherited from class container.HashDecorable
m
 
Constructor Summary
StoredVertex(java.lang.Object o)
          Construct a new vertex storing object o.
 
Method Summary
 java.lang.Object element()
          Get the element at this position.
 void replaceElement(java.lang.Object o)
          Replace the element at this position.
 java.lang.String toString()
          A printable representation of this vertex, such as [vertex @12345 - xyz].
 
Methods inherited from class container.HashDecorable
get, has, put, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface container.Decorable
get, has, put, remove
 

Field Detail

element

java.lang.Object element
Element stored at this vertex.

Constructor Detail

StoredVertex

public StoredVertex(java.lang.Object o)
Construct a new vertex storing object o. Initially, the vertex is not decorated with any attributes.

Method Detail

element

public java.lang.Object element()
Get the element at this position.

Specified by:
element in interface Position

replaceElement

public void replaceElement(java.lang.Object o)
Replace the element at this position.


toString

public java.lang.String toString()
A printable representation of this vertex, such as [vertex @12345 - xyz]. xyz is the element stored at the vertex.

The @12345 part is computed from the vertex's hash code, just as in Object.toString(). It serves to distinguish multiple distinct vertices that might happen to store the same element (e.g., "xyz"). Also, it won't change if we call replaceElement().

Overrides:
toString in class java.lang.Object