org.apache.uima.cas.impl

## Class FsIndex_set_sorted<T extends FeatureStructure>

- java.lang.Object
- - java.util.AbstractCollection<T>
  - - org.apache.uima.cas.impl.FsIndex_singletype<T>
    - - org.apache.uima.cas.impl.FsIndex_set_sorted<T>

- Type Parameters:
    `T` - the Java class type for this index
  All Implemented Interfaces:
    Iterable<T>, Collection<T>, Comparator<FeatureStructure>, FSIndex<T>, LowLevelIndex<T>

      public final class FsIndex_set_sorted<T extends FeatureStructure>
      extends FsIndex_singletype<T>

  Common index impl for set and sorted indexes. Differences: - Number of "equal" (but not identical) FSs: Set: 1, Sorted, N - Iterators: Set: unordered, Sorted: ordered This is an index over just one type (excluding subtypes) Uses key augmented by a least-significant additional key: the _id field of the FS itself, to allow multiple otherwise equal (but not ==) FSs to be in the index.

- - ### Field Summary

    - ### Fields inherited from class org.apache.uima.cas.impl.FsIndex_singletype

      `casImpl, comparatorForIndexSpecs, comparatorNoTypeWithID, comparatorNoTypeWithoutID, comparatorWithID, comparatorWithoutID, isAnnotIdx, type, wr_cow`

    - ### Fields inherited from interface org.apache.uima.cas.impl.LowLevelIndex

      `FS_ID_COMPARATOR, IS_ORDERED, IS_TYPE_ORDER`

    - ### Fields inherited from interface org.apache.uima.cas.FSIndex

      `BAG_INDEX, DEFAULT_BAG_INDEX, SET_INDEX, SORTED_INDEX`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `bulkAddTo(List<T> v)` For serialization: get all the items in this index and bulk add to an List<T>
    `int` | `compare(FeatureStructure o1, FeatureStructure o2)` This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparator
    `boolean` | `contains(FeatureStructure templateKey)` Check if the index contains an element equal to the given feature structure according to the comparators defined for this index.
    `protected CopyOnWriteIndexPart` | `createCopyOnWriteIndexPart()`
    `boolean` | `deleteFS(T fs)`
    `T` | `find(FeatureStructure templateKey)` find any arbitrary matching FS two comparators: cp, and cpx (has extra id comparing) First find an FS in the index that's the smallest that's GE to key using cpx - if none found, then all of the entries in the index are LessThan the key (using cpx); but one might be equal using cp -- if one or more would be equal using cp, it would be because the only reason for the inequality using cpx was due to the _id miscompare.
    `void` | `flush()`
    `LowLevelIterator<T>` | `iterator()` Return an iterator over the index.
    `LowLevelIterator<T>` | `iterator(boolean orderNotNeeded, boolean ignoreType)` Internal use, used by select framework.
    `int` | `ll_maxAnnotSpan()`
    `int` | `size()` Return the number of feature structures in this index.

    - ### Methods inherited from class org.apache.uima.cas.impl.FsIndex_singletype

      `assertFsTypeMatchesIndexType, compare, equals, getCasImpl, getComparator, getComparatorForIndexSpecs, getComparatorImplForIndexSpecs, getCopyOnWriteIndexPart, getIndexingStrategy, getNonNullCow, getType, getTypeImpl, hashCode, isSorted, iterator, ll_compare, ll_iterator, maybeCopy, toString, withSnapshotIterators`

    - ### Methods inherited from class java.util.AbstractCollection

      `add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

    - ### Methods inherited from interface org.apache.uima.cas.impl.LowLevelIndex

      `getIntIterator, getSubIndex, getSubIndex, ll_iterator, select, select, select, select, select`

    - ### Methods inherited from interface org.apache.uima.cas.FSIndex

      `stream, subType, subType`

    - ### Methods inherited from interface java.util.Collection

      `add, addAll, clear, contains, containsAll, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Method Detail

    - #### flush

          public void flush()

      Specified by:
        `flush` in interface `LowLevelIndex<T extends FeatureStructure>`
      Overrides:
        `flush` in class `FsIndex_singletype<T extends FeatureStructure>`

    - #### contains

          public boolean contains(FeatureStructure templateKey)

      Description copied from interface: `FSIndex`

      Check if the index contains an element equal to the given feature structure according to the comparators defined for this index. For bag indexes (which have no comparators), the equality test means the identical feature structure. Note that this is in general not the same as feature structure identity.

      The element is used as a template, and may be a supertype of the type of the index, as long as the keys specified for this index can be accessed.

      Parameters:
        `templateKey` - the feature structure
      Returns:
        true if the fs is contained
      See Also:
        `FSIndex.contains(FeatureStructure)`

    - #### find

          public T find(FeatureStructure templateKey)

      find any arbitrary matching FS two comparators: cp, and cpx (has extra id comparing) First find an FS in the index that's the smallest that's GE to key using cpx - if none found, then all of the entries in the index are LessThan the key (using cpx); but one might be equal using cp -- if one or more would be equal using cp, it would be because the only reason for the inequality using cpx was due to the _id miscompare. Therefore we only need to check the last of the previous ones to see if it is cp equal - if we find one that is GE using cpx, -- if it is equal then return it (any equal one is ok) -- if it is GT, then the ones preceding it are LessThan (using cpx) the key. Do the same check as above to see if the last of the preceding ones is equal using cp.
      Parameters:
        `templateKey` - the matching fs template
      Returns:
        an arbitrary fs that matches
      See Also:
        `FSIterator.moveTo(FeatureStructure)`

    - #### size

          public int size()

      Description copied from interface: `FSIndex`
      Return the number of feature structures in this index.
      Specified by:
        `size` in interface `Collection<T extends FeatureStructure>`
      Specified by:
        `size` in interface `FSIndex<T extends FeatureStructure>`
      Specified by:
        `size` in class `AbstractCollection<T extends FeatureStructure>`
      Returns:
        The number of FSs in this index.
      See Also:
        `FSIndex.size()`

    - #### deleteFS

          public boolean deleteFS(T fs)

      Parameters:
        `fs` - - the Feature Structure to be removed. Only this exact Feature Structure is removed (this is a stronger test than, for example, what moveTo(fs) does, where the fs in that case is used as a template). It is not an error if this exact Feature Structure is not in an index.
      Returns:
        true if something was removed, false if not found

    - #### bulkAddTo

          protected void bulkAddTo(List<T> v)

      Description copied from class: `FsIndex_singletype`
      For serialization: get all the items in this index and bulk add to an List<T>
      Specified by:
        `bulkAddTo` in class `FsIndex_singletype<T extends FeatureStructure>`
      Parameters:
        `v` - the set of items to add

    - #### iterator

          public LowLevelIterator<T> iterator()

      Description copied from interface: `LowLevelIndex`
      Return an iterator over the index. The position of the iterator will be set to return the first item in the index. If the index is empty, the iterator position will be marked as invalid.
      Specified by:
        `iterator` in interface `Iterable<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `Collection<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `FSIndex<T extends FeatureStructure>`
      Specified by:
        `iterator` in interface `LowLevelIndex<T extends FeatureStructure>`
      Specified by:
        `iterator` in class `AbstractCollection<T extends FeatureStructure>`
      Returns:
        An FSIterator positioned at the beginning, or an invalid iterator.

    - #### iterator

          public LowLevelIterator<T> iterator(boolean orderNotNeeded,
                                              boolean ignoreType)

      Description copied from interface: `LowLevelIndex`
      Internal use, used by select framework. Return an iterator over the index. The position of the iterator will be set to return the first item in the index. If the index is empty, the iterator position will be marked as invalid.
      Parameters:
        `orderNotNeeded` - if true, skips work while iterating to keep iterators over multiple types in sync.
        `ignoreType` - if true, the comparator used for moveTo leftmost operations will ignore typeOrder keys, if the index happens to define these
      Returns:
        An FSIterator positioned at the beginning, or an invalid iterator.

    - #### createCopyOnWriteIndexPart

          protected CopyOnWriteIndexPart createCopyOnWriteIndexPart()

      Specified by:
        `createCopyOnWriteIndexPart` in class `FsIndex_singletype<T extends FeatureStructure>`

    - #### ll_maxAnnotSpan

          public int ll_maxAnnotSpan()

      Returns:
        for annotation indexes, an conservative estimate the maximum span between begin and end The value may be larger than actual.

    - #### compare

          public int compare(FeatureStructure o1,
                             FeatureStructure o2)

      Description copied from class: `FsIndex_singletype`
      This is required to avoid compilation error (but not in Eclipse) due to ambiguous interface inheritance from both FeatureStructure and Comparator
      Specified by:
        `compare` in interface `Comparator<FeatureStructure>`
      Specified by:
        `compare` in interface `FSIndex<T extends FeatureStructure>`
      Specified by:
        `compare` in class `FsIndex_singletype<T extends FeatureStructure>`
      Parameters:
        `o1` - the first Feature Structure to compare
        `o2` - the second Feature Structure to compare
      Returns:
        `-1` if `fs1 < fs2`; `0` if `fs1 = fs2`; `1` else.

Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.