prefuse.data.util
Class TreeIndex

java.lang.Object
  extended by prefuse.data.util.TreeIndex
All Implemented Interfaces:
java.util.EventListener, ColumnListener, TableListener, Index

public class TreeIndex
extends java.lang.Object
implements Index, ColumnListener, TableListener

Index instance that uses red-black trees to provide an index over a column of data.

Author:
jeffrey heer

Field Summary
protected  Column m_col
           
protected  int m_colidx
           
protected  IntSortedMap m_index
           
protected  boolean m_reindex
           
protected  RowManager m_rows
           
protected  Table m_table
           
 
Fields inherited from interface prefuse.data.util.Index
TYPE_AEE, TYPE_AEI, TYPE_AIE, TYPE_AII, TYPE_ASCENDING, TYPE_DEE, TYPE_DEI, TYPE_DESCENDING, TYPE_DIE, TYPE_DII, TYPE_LEFT_EXCLUSIVE, TYPE_LEFT_INCLUSIVE, TYPE_RIGHT_EXCLUSIVE, TYPE_RIGHT_INCLUSIVE
 
Constructor Summary
TreeIndex(Table t, RowManager rows, Column col, java.util.Comparator cmp)
          Create a new TreeIndex.
 
Method Summary
 IntIterator allRows(int type)
          Get an iterator over all rows in the index, in sorted order.
 void columnChanged(Column src, int idx, boolean prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, double prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, float prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, int prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int type, int start, int end)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, long prev)
          Notification that a data column has changed.
 void columnChanged(Column src, int idx, java.lang.Object prev)
          Notification that a data column has changed.
 void dispose()
          Dispose of an index, deregistering all listeners.
 int get(double x)
          Get the first row found with the given data value.
 int get(float x)
          Get the first row found with the given data value.
 int get(int x)
          Get the first row found with the given data value.
 int get(long x)
          Get the first row found with the given data value.
 int get(java.lang.Object x)
          Get the first row found with the given data value.
 java.util.Comparator getComparator()
          Get the comparator used to compare column data values.
 void index()
          Perform an initial indexing of a data column.
 int maximum()
          Get the row (or one of the rows) with the maximum data value.
 int median()
          Get the row (or one of the rows) with the median data value.
 int minimum()
          Get the row (or one of the rows) with the minimum data value.
 IntIterator rows(boolean val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(double val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(double lo, double hi, int type)
          Get an iterator over a sorted range of rows.
 IntIterator rows(float val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(float lo, float hi, int type)
          Get an iterator over a sorted range of rows.
 IntIterator rows(int val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(int lo, int hi, int type)
          Get an iterator over a sorted range of rows.
 IntIterator rows(long val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(long lo, long hi, int type)
          Get an iterator over a sorted range of rows.
 IntIterator rows(java.lang.Object val)
          Get an iterator over all rows with the given data value.
 IntIterator rows(java.lang.Object lo, java.lang.Object hi, int type)
          Get an iterator over a sorted range of rows.
 int size()
          Get the size of this index, the number of data value / row pairs included.
 void tableChanged(Table t, int start, int end, int col, int type)
          Notification that a table has changed.
 int uniqueCount()
          Get the number of unique data values in the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_table

protected Table m_table

m_rows

protected RowManager m_rows

m_col

protected Column m_col

m_index

protected IntSortedMap m_index

m_reindex

protected boolean m_reindex

m_colidx

protected int m_colidx
Constructor Detail

TreeIndex

public TreeIndex(Table t,
                 RowManager rows,
                 Column col,
                 java.util.Comparator cmp)
          throws IncompatibleComparatorException
Create a new TreeIndex.

Parameters:
t - the Table containing the data column to index
rows - the RowManager of the Table
col - the Column instance to index
cmp - the Comparator to use to sort data values
Throws:
IncompatibleComparatorException - if the comparator is not compatible with the column's data type
Method Detail

dispose

public void dispose()
Description copied from interface: Index
Dispose of an index, deregistering all listeners.

Specified by:
dispose in interface Index
See Also:
Index.dispose()

getComparator

public java.util.Comparator getComparator()
Description copied from interface: Index
Get the comparator used to compare column data values.

Specified by:
getComparator in interface Index
Returns:
the sort comparator
See Also:
Index.getComparator()

size

public int size()
Description copied from interface: Index
Get the size of this index, the number of data value / row pairs included.

Specified by:
size in interface Index
Returns:
the size of the index
See Also:
Index.size()

index

public void index()
Description copied from interface: Index
Perform an initial indexing of a data column.

Specified by:
index in interface Index
See Also:
Index.index()

tableChanged

public void tableChanged(Table t,
                         int start,
                         int end,
                         int col,
                         int type)
Description copied from interface: TableListener
Notification that a table has changed.

Specified by:
tableChanged in interface TableListener
Parameters:
t - the table that has changed
start - the starting row index of the changed table region
end - the ending row index of the changed table region
col - the column that has changed, or EventConstants.ALL_COLUMNS if the operation affects all columns
type - the type of modification, one of EventConstants.INSERT, EventConstants.DELETE, or EventConstants.UPDATE.
See Also:
TableListener.tableChanged(prefuse.data.Table, int, int, int, int)

columnChanged

public void columnChanged(Column src,
                          int type,
                          int start,
                          int end)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
type - One of EventConstants.INSERT, EventConstants.DELETE, or EventConstants.UPDATE.
start - the first column index that has been changed
end - the last column index that has been changed
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, int, int)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          boolean prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, boolean)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          int prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, int)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          long prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, long)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          float prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, float)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          double prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, double)

columnChanged

public void columnChanged(Column src,
                          int idx,
                          java.lang.Object prev)
Description copied from interface: ColumnListener
Notification that a data column has changed.

Specified by:
columnChanged in interface ColumnListener
Parameters:
src - the column that has changed
idx - the column row index that has changed
prev - the previous value at the given location
See Also:
ColumnListener.columnChanged(prefuse.data.column.Column, int, java.lang.Object)

minimum

public int minimum()
Description copied from interface: Index
Get the row (or one of the rows) with the minimum data value.

Specified by:
minimum in interface Index
Returns:
a row with a minimum data value
See Also:
Index.minimum()

maximum

public int maximum()
Description copied from interface: Index
Get the row (or one of the rows) with the maximum data value.

Specified by:
maximum in interface Index
Returns:
a row with a maximum data value
See Also:
Index.maximum()

median

public int median()
Description copied from interface: Index
Get the row (or one of the rows) with the median data value.

Specified by:
median in interface Index
Returns:
a row with a median data value
See Also:
Index.median()

uniqueCount

public int uniqueCount()
Description copied from interface: Index
Get the number of unique data values in the index.

Specified by:
uniqueCount in interface Index
Returns:
the number of unique data values
See Also:
Index.uniqueCount()

allRows

public IntIterator allRows(int type)
Description copied from interface: Index
Get an iterator over all rows in the index, in sorted order.

Specified by:
allRows in interface Index
Parameters:
type - the sort type, one of Index.TYPE_ASCENDING or Index.TYPE_DESCENDING.
Returns:
an iterator over all rows in the index
See Also:
Index.allRows(int)

rows

public IntIterator rows(java.lang.Object lo,
                        java.lang.Object hi,
                        int type)
Description copied from interface: Index
Get an iterator over a sorted range of rows.

Specified by:
rows in interface Index
Parameters:
lo - the minimum data value
hi - the maximum data value
type - the iteration type, one of the composite flags involving both a sort order, and whether each bound of the range should inclusive or exclusive
Returns:
an iterator over a sorted range of rows
See Also:
Index.rows(java.lang.Object, java.lang.Object, int)

rows

public IntIterator rows(int lo,
                        int hi,
                        int type)
Description copied from interface: Index
Get an iterator over a sorted range of rows.

Specified by:
rows in interface Index
Parameters:
lo - the minimum data value
hi - the maximum data value
type - the iteration type, one of the composite flags involving both a sort order, and whether each bound of the range should inclusive or exclusive
Returns:
an iterator over a sorted range of rows
See Also:
Index.rows(int, int, int)

rows

public IntIterator rows(long lo,
                        long hi,
                        int type)
Description copied from interface: Index
Get an iterator over a sorted range of rows.

Specified by:
rows in interface Index
Parameters:
lo - the minimum data value
hi - the maximum data value
type - the iteration type, one of the composite flags involving both a sort order, and whether each bound of the range should inclusive or exclusive
Returns:
an iterator over a sorted range of rows
See Also:
Index.rows(long, long, int)

rows

public IntIterator rows(float lo,
                        float hi,
                        int type)
Description copied from interface: Index
Get an iterator over a sorted range of rows.

Specified by:
rows in interface Index
Parameters:
lo - the minimum data value
hi - the maximum data value
type - the iteration type, one of the composite flags involving both a sort order, and whether each bound of the range should inclusive or exclusive
Returns:
an iterator over a sorted range of rows
See Also:
Index.rows(float, float, int)

rows

public IntIterator rows(double lo,
                        double hi,
                        int type)
Description copied from interface: Index
Get an iterator over a sorted range of rows.

Specified by:
rows in interface Index
Parameters:
lo - the minimum data value
hi - the maximum data value
type - the iteration type, one of the composite flags involving both a sort order, and whether each bound of the range should inclusive or exclusive
Returns:
an iterator over a sorted range of rows
See Also:
Index.rows(double, double, int)

rows

public IntIterator rows(int val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(int)

rows

public IntIterator rows(long val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(long)

rows

public IntIterator rows(float val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(float)

rows

public IntIterator rows(double val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(double)

rows

public IntIterator rows(boolean val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(boolean)

rows

public IntIterator rows(java.lang.Object val)
Description copied from interface: Index
Get an iterator over all rows with the given data value.

Specified by:
rows in interface Index
Parameters:
val - the data value
Returns:
an iterator over all rows matching the data value
See Also:
Index.rows(java.lang.Object)

get

public int get(double x)
Description copied from interface: Index
Get the first row found with the given data value.

Specified by:
get in interface Index
Parameters:
x - the data value
Returns:
the first row matching the data value
See Also:
Index.get(double)

get

public int get(float x)
Description copied from interface: Index
Get the first row found with the given data value.

Specified by:
get in interface Index
Parameters:
x - the data value
Returns:
the first row matching the data value
See Also:
Index.get(float)

get

public int get(int x)
Description copied from interface: Index
Get the first row found with the given data value.

Specified by:
get in interface Index
Parameters:
x - the data value
Returns:
the first row matching the data value
See Also:
Index.get(int)

get

public int get(long x)
Description copied from interface: Index
Get the first row found with the given data value.

Specified by:
get in interface Index
Parameters:
x - the data value
Returns:
the first row matching the data value
See Also:
Index.get(long)

get

public int get(java.lang.Object x)
Description copied from interface: Index
Get the first row found with the given data value.

Specified by:
get in interface Index
Parameters:
x - the data value
Returns:
the first row matching the data value
See Also:
Index.get(java.lang.Object)


Copyright © 2007 Regents of the University of California