com.jgpruitt.datamodeler.core
Class IndexSet

java.lang.Object
  extended by com.jgpruitt.datamodeler.core.IndexSet
All Implemented Interfaces:
java.lang.Iterable<Index>

public class IndexSet
extends java.lang.Object
implements java.lang.Iterable<Index>

IndexSet is a collection of Indexes in which each column must have a unique name. The collection maintains the order in which the elements are added. The implementation guarantees constant time getting of Indexes by name or ordinal.

Author:
John Pruitt

Field Summary
protected  java.util.List<Index> list
           
protected  java.util.Map<java.lang.String,Index> map
           
protected  Table table
           
 
Constructor Summary
IndexSet(Table table)
          Constructor.
 
Method Summary
 Index add(Index ix)
          Adds an Index to the set.
 boolean contains(Index ix)
          Tests whether the given Index is in the set.
 boolean contains(java.lang.String name)
          Tests whether the set contains an Index by the given name
 Index get(int index)
          Gets the Index at the given index in the set.
 Index get(java.lang.String name)
          Gets an Index from the set by the Index's name
 boolean isEmpty()
          Gets whether or not the set has no elements
 java.util.Iterator<Index> iterator()
          Gets an Iterator over the Indexes in the set.
 int size()
          Gets the number of Indexes in the set.
 Table table()
          Gets the Table being indexed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected final Table table

map

protected final java.util.Map<java.lang.String,Index> map

list

protected final java.util.List<Index> list
Constructor Detail

IndexSet

public IndexSet(Table table)
Constructor.

Parameters:
table - the Table being indexed
See Also:
IndexSet
Method Detail

add

public Index add(Index ix)
Adds an Index to the set.

Parameters:
ix - the Index to add
Returns:
the Index that was added

table

public Table table()
Gets the Table being indexed

Returns:
the Table

get

public Index get(int index)
Gets the Index at the given index in the set.

Parameters:
index - the index of the Index to retrieve
Returns:
the Index

get

public Index get(java.lang.String name)
Gets an Index from the set by the Index's name

Parameters:
name - the name of the Index to get
Returns:
the Index

contains

public boolean contains(java.lang.String name)
Tests whether the set contains an Index by the given name

Parameters:
name - the name of the Index to test for
Returns:
true if the set contains an Index by the given name

contains

public boolean contains(Index ix)
Tests whether the given Index is in the set.

Parameters:
ix - the Index to test for
Returns:
true if the Index is in the set

iterator

public java.util.Iterator<Index> iterator()
Gets an Iterator over the Indexes in the set.

Specified by:
iterator in interface java.lang.Iterable<Index>
Returns:
the Iterator

isEmpty

public boolean isEmpty()
Gets whether or not the set has no elements

Returns:
true if the set is empty

size

public int size()
Gets the number of Indexes in the set.

Returns:
the number of Indexes in the set.