edu.uci.ics.jung.graph.decorators
Class Indexer

java.lang.Object
  extended by edu.uci.ics.jung.graph.decorators.Indexer

public class Indexer
extends Object

An Indexer applies an index to a Graph. The Indexer, specifically, attaches itself to a Graph's UserData and keeps a set of vertex keys as integers. An indexer can be used to look up both forward (Vertex - Index) and backward (Index - Vertex) . FIXME: note that there's currently no way to ask an Indexer instance what its offset is.

Author:
danyelf

Method Summary
static Indexer getAndUpdateIndexer(ArchetypeGraph g)
          Gets the indexer associated with this graph.
static Indexer getAndUpdateIndexer(ArchetypeGraph g, Object key)
          Gets the indexer associated with this graph.
 int getIndex(ArchetypeVertex v)
          Gets the index assocated with this vertex.
static Indexer getIndexer(ArchetypeGraph g)
          Gets the indexer associated with this graph.
static Indexer getIndexer(ArchetypeGraph g, Object key)
          * Gets an indexer associated with this graph at this key
 ArchetypeVertex getVertex(int i)
          Gets the vertex associated with this index.
static boolean hasIndexer(ArchetypeGraph g)
          Checks if there is an indexer assocated with this graph.
static boolean hasIndexer(ArchetypeGraph g, Object key)
          Checks if there is an indexer assocated with this graph.
static Indexer newIndexer(ArchetypeGraph g, int offset)
          Creates a new indexer associated with this graph.
 void updateIndex()
          Forces an index update, reindexing from zero.
 void updateIndex(int offset)
          Clears previous index (if it existed); puts in a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getIndexer

public static Indexer getIndexer(ArchetypeGraph g)
Gets the indexer associated with this graph. This uses the default INDEX_DEFAULT_KEY as its user data key.

Throws:
FatalException - if the graph has changed detectably since the last run. Note that "has changed" merely looks at the number of nodes for now.

getAndUpdateIndexer

public static Indexer getAndUpdateIndexer(ArchetypeGraph g)
Gets the indexer associated with this graph. Forces the system to create a new Index on the graph. This uses the default INDEX_DEFAULT_KEY as its user data key.


newIndexer

public static Indexer newIndexer(ArchetypeGraph g,
                                 int offset)
Creates a new indexer associated with this graph. Starts the count at "offset". WARNING: This graph may be hard to use in some other methods that assume a zero offset. If the Graph has changed, this will update the index. Note that the "has Changed" parameter is a little thin; it merely checks whether the size has changed or not This uses the default INDEX_DEFAULT_KEY as its user data key.

Parameters:
g - the Graph to index.
offset - a starting value to index from
Returns:
an indexer that has been indexed

getIndexer

public static Indexer getIndexer(ArchetypeGraph g,
                                 Object key)
* Gets an indexer associated with this graph at this key

Parameters:
g - The graph to check
key - The user data key to check
Returns:
the indexer
Throws:
FatalException - if the graph has changed detectably since the last run. Note that "has changed" merely looks at the number of nodes for now.

getAndUpdateIndexer

public static Indexer getAndUpdateIndexer(ArchetypeGraph g,
                                          Object key)
Gets the indexer associated with this graph. Forces the system to create a new Index on the graph at the given key.

Throws:
FatalException - if the graph has changed detectably since the last run. Note that "has changed" merely looks at the number of nodes for now.

hasIndexer

public static boolean hasIndexer(ArchetypeGraph g)
Checks if there is an indexer assocated with this graph. This uses the default INDEX_DEFAULT_KEY as its user data key.

Parameters:
g - The graph to check
Returns:
true if there is an indexer associated with this graph.

hasIndexer

public static boolean hasIndexer(ArchetypeGraph g,
                                 Object key)
Checks if there is an indexer assocated with this graph.

Parameters:
g - The graph to check
Returns:
true if there is an indexer associated with this graph.

updateIndex

public void updateIndex(int offset)
Clears previous index (if it existed); puts in a new one. Merely follows graph.getVertices() iterator order, which is not guaranteed to have any nice properties at all. When complete, the index will be numbered from offset to offset + n - 1 (where n = g.numVertices()), and will be accessible through getIndex( Vertex) and getVertex( index ).


updateIndex

public void updateIndex()
Forces an index update, reindexing from zero. Equivalent to updateIndex(0).


getIndex

public int getIndex(ArchetypeVertex v)
Gets the index assocated with this vertex.


getVertex

public ArchetypeVertex getVertex(int i)
Gets the vertex associated with this index.