Class FsIterator_subtypes_ordered<T extends FeatureStructure>

  • Type Parameters:
    T - result type
    All Implemented Interfaces:
    java.util.Iterator<T>, java.util.ListIterator<T>, FSIterator<T>, LowLevelIterator<T>

    public class FsIterator_subtypes_ordered<T extends FeatureStructure>
    extends FsIterator_multiple_indexes<T>
    Performs an ordered iteration among a set of iterators, each one corresponding to the type or subtype of the uppermost type. The set of iterators is maintained in an array, with the 0th element being the current valid iterator.
    • Field Detail

      • SORTED_SECTION

        private static final int SORTED_SECTION
        The number of elements to keep in order before the binary heap starts. This section helps the performance in cases where a couple of types dominate the index. The sorted section is searched sequentially. Above the sorted section, the search is done using binary search
        See Also:
        Constant Field Values
      • lastValidIteratorIndex

        protected int lastValidIteratorIndex
        index into nonEmptyIterators, shows last valid one
      • wentForward

        private boolean wentForward
    • Constructor Detail

      • FsIterator_subtypes_ordered

        public FsIterator_subtypes_ordered​(FsIndex_iicp<T> iicp,
                                           java.util.Comparator<TOP> comparatorMaybeNoTypeWithoutId)
    • Method Detail

      • moveToFirstNoReinit

        public void moveToFirstNoReinit()
        Move operators have to move a group of iterators for this type and all its subtypes
      • moveToLastNoReinit

        public void moveToLastNoReinit()
        Description copied from interface: LowLevelIterator
        Internal use same as moveToLast, but won't reset to use current contents of index if index has changed
      • moveToNextNvc

        public void moveToNextNvc()
        Description copied from interface: FSIterator
        version of moveToNext which bypasses the isValid check - call only if you've just done this check yourself
      • moveToNextCmn

        private void moveToNextCmn​(LowLevelIterator<T> it0)
        Parameters:
        it0 - guaranteed to be a valid iterator by callers
      • moveToPreviousNvc

        public void moveToPreviousNvc()
        Description copied from interface: FSIterator
        version of moveToPrevious which bypasses the isValid check - call only if you've just done this check yourself
      • is_before

        private boolean is_before​(LowLevelIterator<T> l,
                                  LowLevelIterator<T> r,
                                  int dir)
        Test the order with which the two iterators should be used. Introduces arbitrary ordering for equivalent FSs. Only called with valid iterators.
        Parameters:
        l - - guaranteed to ba a valid iterator by callers
        r - - guaranteed to be a valid iterator by callers
        dir - Direction of movement, 1 for forward, -1 for backward
        Returns:
        true if the left iterator needs to be used before the right one.
      • compare

        private int compare​(FeatureStructure fsLeft,
                            FeatureStructure fsRight)
        Only used to compare two iterator's with different types position
        Parameters:
        fsLeft - the left iterator's element
        fsRight - the right iterator's element
        Returns:
        1 if left > right, (compare maybe ignores type) -1 if left < right, (compare maybe ignores type) 1 if left == right and left.id > right.id -1 if left == right and left.id < right.id
      • heapify_up

        private void heapify_up​(LowLevelIterator<T> it,
                                int idx,
                                int dir)
        Move the idx'th iterator element up in the heap until it finds its proper position. Up means previous iterators are before it
        Parameters:
        it - indexes[idx], guaranteed to be "valid"
        idx - Element to move, nonEmptyIterators[i] == it
        dir - Direction of iterator movement, 1 for forward, -1 for backward
      • heapify_down

        private void heapify_down​(LowLevelIterator<T> it,
                                  int dir)
        Move the top element down in the heap until it finds its proper position.
        Parameters:
        it - indexes[0], may be invalid
        dir - Direction of iterator movement, 1 for forward, -1 for backward
      • isValid

        public boolean isValid()
        Description copied from interface: FSIterator
        Check if this iterator is valid.
        Returns:
        true if the iterator is valid.
      • getNvc

        public T getNvc()
                 throws java.util.NoSuchElementException
        Description copied from interface: FSIterator
        Get the structure the iterator is pointing at. Throws various unchecked exceptions, if the iterator is not valid
        Returns:
        The structure the iterator is pointing at.
        Throws:
        java.util.NoSuchElementException
      • moveToNoReinit

        public void moveToNoReinit​(FeatureStructure fs)
        Description copied from interface: LowLevelIterator
        Internal use same as moveTo(fs), but won't reset to use current contents of index if index has changed
        Parameters:
        fs - the fs to use as the template identifying the place to move to
      • copy

        public FSIterator<T> copy()
        Description copied from interface: FSIterator
        Copy this iterator.
        Returns:
        A copy of this iterator, pointing at the same element.
      • getComparator

        public java.util.Comparator<TOP> getComparator()
        Returns:
        the comparator used by this iterator. It is always a withoutID style, and may be either a withType or NoType style.
      • isMoveToSupported

        public boolean isMoveToSupported()
        Returns:
        false if this iterator is over an unordered collection or set or bag
      • dumpIteratorInfo

        private void dumpIteratorInfo​(java.lang.String context)