Class IntArrayPredicateIterator

java.lang.Object
org.carrot2.util.IntArrayPredicateIterator
All Implemented Interfaces:
Iterator<Integer>

public final class IntArrayPredicateIterator extends Object implements Iterator<Integer>
Iterates over ranges between elements for which a given predicate returns true . The returned range may be of zero length (getLength()).

An example probably best explains what this class does. Consider the following array:

 [SEP, SEP, 1, SEP]
 
where SEP is something for which the predicate returns true. If so, then the returned subranges would be equal to (start index, length):
 [0,0]  (empty range before the first separator)
 [1,0]  (empty range after the first separator)
 [2,1]  ([1])
 [4,0]  (empty range after last separator)
 
  • Constructor Details

    • IntArrayPredicateIterator

      public IntArrayPredicateIterator(short[] array, int from, int length, com.carrotsearch.hppc.predicates.ShortPredicate separator)
    • IntArrayPredicateIterator

      public IntArrayPredicateIterator(short[] array, com.carrotsearch.hppc.predicates.ShortPredicate separator)
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<Integer>
    • next

      public Integer next()
      Specified by:
      next in interface Iterator<Integer>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<Integer>
    • getLength

      public int getLength()
      Returns the length (number of elements) of the range most recently acquired from next().