Class FsIterator_limited<T extends FeatureStructure>

  • All Implemented Interfaces:
    java.util.Iterator<T>, java.util.ListIterator<T>, FSIterator<T>, LowLevelIterator<T>

    class FsIterator_limited<T extends FeatureStructure>
    extends java.lang.Object
    implements LowLevelIterator<T>
    Wraps FSIterator, limits results to n gets. Moving the iterator around does not count towards the limit.
    • Field Detail

      • limit

        private final int limit
      • count

        private int count
      • limitReached

        private boolean limitReached
    • Constructor Detail

      • FsIterator_limited

        FsIterator_limited​(FSIterator<T> iterator,
                           int limit)
    • Method Detail

      • maybeMakeInvalid

        private void maybeMakeInvalid()
      • getNvc

        public T getNvc()
        Description copied from interface: FSIterator
        Get the structure the iterator is pointing at. Throws various unchecked exceptions, if the iterator is not valid
        Specified by:
        getNvc in interface FSIterator<T extends FeatureStructure>
        Returns:
        The structure the iterator is pointing at.
      • 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
        Specified by:
        moveToNextNvc in interface FSIterator<T extends FeatureStructure>
      • 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
        Specified by:
        moveToPreviousNvc in interface FSIterator<T extends FeatureStructure>
      • 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
        Specified by:
        moveToNoReinit in interface LowLevelIterator<T extends FeatureStructure>
        Parameters:
        fs - the fs to use as the template identifying the place to move to
      • isValid

        public boolean isValid()
        Description copied from interface: FSIterator
        Check if this iterator is valid.
        Specified by:
        isValid in interface FSIterator<T extends FeatureStructure>
        Returns:
        true if the iterator is valid.
      • ll_indexSizeMaybeNotCurrent

        public int ll_indexSizeMaybeNotCurrent()
        Specified by:
        ll_indexSizeMaybeNotCurrent in interface LowLevelIterator<T extends FeatureStructure>
        Returns:
        The size of the index. In case of copy-on-write, this returns the size of the index at the time the iterator was created, or at the last moveTo, moveToFirst, or moveToLast. To get the current index size, use ll_getIndex().getSize()
      • isIndexesHaveBeenUpdated

        public boolean isIndexesHaveBeenUpdated()
        Specified by:
        isIndexesHaveBeenUpdated in interface LowLevelIterator<T extends FeatureStructure>
        Returns:
        true if one or more of the underlying indexes this iterator goes over, has been updated since initialization or resetting operation (moveToFirst/Last/feature_structure). This includes empty iterators becoming non-empty.
      • getComparator

        public java.util.Comparator<TOP> getComparator()
        Specified by:
        getComparator in interface LowLevelIterator<T extends FeatureStructure>
        Returns:
        the comparator used by this iterator. It is always a withoutID style, and may be either a withType or NoType style.
      • size

        public int size()
        Description copied from interface: FSIterator
        return the size of the collection being iterated over, if available. Because the iterator can move forwards and backwards, the size is the total size that the iterator would iterate over, starting at the first element thru the last element. This may be inefficient to compute.
        Specified by:
        size in interface FSIterator<T extends FeatureStructure>
        Returns:
        the size of the collection being iterated over.