|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FSIndex<T extends FeatureStructure>
Feature structure index access interface.
Notice that each feature structure index uses its own ordering relation that will usually be different from index to index. In particular, equality with respect to the index ordering will in general not imply object identity for the feature structures.
We currently support three different kinds of indexes: sorted, set and bag indexes. The default index is a sorted index. In a sorted index, all FSs that are committed are entered, even if they are duplicates of already existing FSs. The index is sorted in the sense that iterators will output FSs in sorted order according to the comparator for that index. The order of FSs that are equal wrt the comparator is arbitrary but fixed. That is, if you iterate over the same index several times, you will see the same relative order of FSs every time. We also guarantee that reverse iterators will produce exactly the reverse sequence of forward iteration.
A set index will contain no duplicates of the same type, where a duplicate is defined by the indexing comparator. That is, if you commit two feature structures of the same type that are equal wrt the indexing comparator, only the first one will be entered into the index. Note that you can still have duplicates wrt the indexing order if they are of a different type. A set index is not guaranteed to be sorted.
A bag index finally simply stores everything, without any guaranteed order. Our current implementation works such that for any two FSs of the same type, they will be returned in the order in which they are committed (FIFO style). Note that any operation like find() or FSIterator.moveTo() will not produce useful results on bag indexes, since bag indexes do not honor comparators. Only use a bag index if you want very fast adding and will have to iterate over the whole index anyway.
Field Summary | |
---|---|
static int |
BAG_INDEX
Indexing strategy: bag index. |
static int |
DEFAULT_BAG_INDEX
Special indexes used by the framework to implement FSIndexRepository.getAllIndexedFS(Type) . |
static int |
SET_INDEX
Indexing strategy: set index. |
static int |
SORTED_INDEX
Indexing strategy: sorted index. |
Method Summary | |
---|---|
int |
compare(FeatureStructure fs1,
FeatureStructure fs2)
Compare two feature structures according to the ordering relation of the index. |
boolean |
contains(FeatureStructure fs)
Check if the index contains an element equal to the given feature structure according to the ordering of the index. |
FeatureStructure |
find(FeatureStructure fs)
Find an entry in the index equal to the given feature structure according to the ordering of the index. |
int |
getIndexingStrategy()
Return the indexing strategy. |
Type |
getType()
Return the type of feature structures this index contains. |
FSIterator<T> |
iterator()
Return an iterator over the index. |
FSIterator<T> |
iterator(FeatureStructure fs)
Return an iterator over the index. |
int |
size()
Return the number of feature structures in this index. |
Field Detail |
---|
static final int SORTED_INDEX
static final int SET_INDEX
static final int BAG_INDEX
static final int DEFAULT_BAG_INDEX
FSIndexRepository.getAllIndexedFS(Type)
. Not user-definable.
Method Detail |
---|
int size()
Type getType()
boolean contains(FeatureStructure fs)
fs
- The FS we're looking for.
true
if the index contains such an element.FeatureStructure find(FeatureStructure fs)
fs
- The FS we're looking for.
fs
, or null
if no such FS exists.FSIterator.moveTo(FeatureStructure)
int compare(FeatureStructure fs1, FeatureStructure fs2)
-1
if fs1 < fs2
; 0
if
fs1 = fs2
; 1
else.FSIterator<T> iterator()
iterator
in interface Iterable<T extends FeatureStructure>
FSIterator<T> iterator(FeatureStructure fs)
get()
method is
greater than or equal to fs
, and any previous FS is less than FS
.
If no such position exists, the iterator will be invalid.
fs
- The feature structure at which the iterator should be positioned.
fs
, if it exists. An invalid iterator, else.int getIndexingStrategy()
SORTED_INDEX
, BAG_INDEX
or SET_INDEX
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |