KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > util > Index


1 package prefuse.data.util;
2
3 import java.util.Comparator JavaDoc;
4
5 import prefuse.util.collections.IntIterator;
6
7
8 /**
9  * Represents an index over a column of data, allowing quick lookups by
10  * data value and providing iterators over sorted ranges of data. For
11  * convenience, there are index lookup methods for a variety of data
12  * types; which ones to use depend on the data type of the column
13  * being indexed and calling a lookup method for an incompatible
14  * data type could lead to an exception being thrown.
15  *
16  * @author <a HREF="http://jheer.org">jeffrey heer</a>
17  */

18 public interface Index {
19
20     /** Flag for an ascending sort order. */
21     public static final int TYPE_ASCENDING = 1<<5;
22     /** Flag for a descending sort order. */
23     public static final int TYPE_DESCENDING = 1<<4;
24     /** Flag for including the lowest value of a range. */
25     public static final int TYPE_LEFT_INCLUSIVE = 1<<3;
26     /** Flag for excluding the lowest value of a range. */
27     public static final int TYPE_LEFT_EXCLUSIVE = 1<<2;
28     /** Flag for including the highest value of a range. */
29     public static final int TYPE_RIGHT_INCLUSIVE = 1<<1;
30     /** Flag for excluding the highest value of a range. */
31     public static final int TYPE_RIGHT_EXCLUSIVE = 1;
32     
33     /** Composite flag for an ascending, left and right inclusive range. */
34     public static final int TYPE_AII =
35         TYPE_ASCENDING | TYPE_LEFT_INCLUSIVE | TYPE_RIGHT_INCLUSIVE;
36     /** Composite flag for a descending, left and right inclusive range. */
37     public static final int TYPE_DII =
38         TYPE_DESCENDING | TYPE_LEFT_INCLUSIVE | TYPE_RIGHT_INCLUSIVE;
39     /** Composite flag for an ascending, left exclusive, right inclusive
40      * range. */

41     public static final int TYPE_AEI =
42         TYPE_ASCENDING | TYPE_LEFT_EXCLUSIVE | TYPE_RIGHT_INCLUSIVE;
43     /** Composite flag for a descending, left exclusive, right inclusive
44     * range. */

45     public static final int TYPE_DEI =
46         TYPE_DESCENDING | TYPE_LEFT_EXCLUSIVE | TYPE_RIGHT_INCLUSIVE;
47     /** Composite flag for an ascending, left inclusive, right exclusive
48      * range. */

49     public static final int TYPE_AIE =
50         TYPE_ASCENDING | TYPE_LEFT_INCLUSIVE | TYPE_RIGHT_EXCLUSIVE;
51     /** Composite flag for a descending, left inclusive, right exclusive
52      * range. */

53     public static final int TYPE_DIE =
54         TYPE_DESCENDING | TYPE_LEFT_INCLUSIVE | TYPE_RIGHT_EXCLUSIVE;
55     /** Composite flag for an ascending, left and right exclusive range. */
56     public static final int TYPE_AEE =
57         TYPE_ASCENDING | TYPE_LEFT_EXCLUSIVE | TYPE_RIGHT_EXCLUSIVE;
58     /** Composite flag for a descending, left and right exclusive range. */
59     public static final int TYPE_DEE =
60         TYPE_DESCENDING | TYPE_LEFT_EXCLUSIVE | TYPE_RIGHT_EXCLUSIVE;
61     
62     /**
63      * Perform an initial indexing of a data column.
64      */

65     public void index();
66     
67     /**
68      * Dispose of an index, deregistering all listeners.
69      */

70     public void dispose();
71     
72     /**
73      * Get the comparator used to compare column data values.
74      * @return the sort comparator
75      */

76     public Comparator JavaDoc getComparator();
77     
78     /**
79      * Get the row (or one of the rows) with the minimum data value.
80      * @return a row with a minimum data value
81      */

82     public int minimum();
83     
84     /**
85      * Get the row (or one of the rows) with the maximum data value.
86      * @return a row with a maximum data value
87      */

88     public int maximum();
89     
90     /**
91      * Get the row (or one of the rows) with the median data value.
92      * @return a row with a median data value
93      */

94     public int median();
95     
96     /**
97      * Get the number of unique data values in the index.
98      * @return the number of unique data values
99      */

100     public int uniqueCount();
101     
102     /**
103      * Get the size of this index, the number of data value / row
104      * pairs included.
105      * @return the size of the index
106      */

107     public int size();
108     
109     /**
110      * Get an iterator over all rows in the index, in sorted order.
111      * @param type the sort type, one of {@link #TYPE_ASCENDING} or
112      * {@link #TYPE_DESCENDING}.
113      * @return an iterator over all rows in the index
114      */

115     public IntIterator allRows(int type);
116     
117     /**
118      * Get an iterator over a sorted range of rows.
119      * @param lo the minimum data value
120      * @param hi the maximum data value
121      * @param type the iteration type, one of the composite flags
122      * involving both a sort order, and whether each bound of
123      * the range should inclusive or exclusive
124      * @return an iterator over a sorted range of rows
125      */

126     public IntIterator rows(Object JavaDoc lo, Object JavaDoc hi, int type);
127     
128     /**
129      * Get an iterator over a sorted range of rows.
130      * @param lo the minimum data value
131      * @param hi the maximum data value
132      * @param type the iteration type, one of the composite flags
133      * involving both a sort order, and whether each bound of
134      * the range should inclusive or exclusive
135      * @return an iterator over a sorted range of rows
136      */

137     public IntIterator rows(int lo, int hi, int type);
138     
139     /**
140      * Get an iterator over a sorted range of rows.
141      * @param lo the minimum data value
142      * @param hi the maximum data value
143      * @param type the iteration type, one of the composite flags
144      * involving both a sort order, and whether each bound of
145      * the range should inclusive or exclusive
146      * @return an iterator over a sorted range of rows
147      */

148     public IntIterator rows(long lo, long hi, int type);
149     
150     /**
151      * Get an iterator over a sorted range of rows.
152      * @param lo the minimum data value
153      * @param hi the maximum data value
154      * @param type the iteration type, one of the composite flags
155      * involving both a sort order, and whether each bound of
156      * the range should inclusive or exclusive
157      * @return an iterator over a sorted range of rows
158      */

159     public IntIterator rows(float lo, float hi, int type);
160     
161     /**
162      * Get an iterator over a sorted range of rows.
163      * @param lo the minimum data value
164      * @param hi the maximum data value
165      * @param type the iteration type, one of the composite flags
166      * involving both a sort order, and whether each bound of
167      * the range should inclusive or exclusive
168      * @return an iterator over a sorted range of rows
169      */

170     public IntIterator rows(double lo, double hi, int type);
171
172     /**
173      * Get an iterator over all rows with the given data value.
174      * @param val the data value
175      * @return an iterator over all rows matching the data value
176      */

177     public IntIterator rows(Object JavaDoc val);
178
179     /**
180      * Get an iterator over all rows with the given data value.
181      * @param val the data value
182      * @return an iterator over all rows matching the data value
183      */

184     public IntIterator rows(int val);
185     
186     /**
187      * Get an iterator over all rows with the given data value.
188      * @param val the data value
189      * @return an iterator over all rows matching the data value
190      */

191     public IntIterator rows(long val);
192     
193     /**
194      * Get an iterator over all rows with the given data value.
195      * @param val the data value
196      * @return an iterator over all rows matching the data value
197      */

198     public IntIterator rows(float val);
199     
200     /**
201      * Get an iterator over all rows with the given data value.
202      * @param val the data value
203      * @return an iterator over all rows matching the data value
204      */

205     public IntIterator rows(double val);
206     
207     /**
208      * Get an iterator over all rows with the given data value.
209      * @param val the data value
210      * @return an iterator over all rows matching the data value
211      */

212     public IntIterator rows(boolean val);
213     
214     /**
215      * Get the first row found with the given data value.
216      * @param x the data value
217      * @return the first row matching the data value
218      */

219     public int get(Object JavaDoc x);
220     
221     /**
222      * Get the first row found with the given data value.
223      * @param x the data value
224      * @return the first row matching the data value
225      */

226     public int get(int x);
227     
228     /**
229      * Get the first row found with the given data value.
230      * @param x the data value
231      * @return the first row matching the data value
232      */

233     public int get(long x);
234     
235     /**
236      * Get the first row found with the given data value.
237      * @param x the data value
238      * @return the first row matching the data value
239      */

240     public int get(float x);
241     
242     /**
243      * Get the first row found with the given data value.
244      * @param x the data value
245      * @return the first row matching the data value
246      */

247     public int get(double x);
248     
249 } // end of interface Index
250
Popular Tags