# The Java SequenceIterator Class

SequenceIterator is used to iterate `sequence` fields. Note that iteration is performed in tile mode; i.e. more than one `sequence` items are fetched at each iteration.

All these items in the tile can be obtained using method `tileItems()`. The main iterator method is `nextTile()` which position the iterator on the next tile. The size of a tile is implementation specific; currently the size is 100 items but at the end of a sequence the tile may be shorter.

An alternative way of performing iteration is to use the `get()` method. This method extracts items into a provided array. If iteration in scalar mode (item-by-item) is preferred, then an array with size 1 can be passed to the `get()` method.

### For an overview see page Java Classes

### Class Definitions

        public  class SequenceIterator implements java.io.Closeable
        {
            long handle;

            SequenceIterator(long hnd)
            {
                handle = hnd;
            }

            // Iterator Methods
            public int get(Object buffer)  {…};
               public Object next()  {…};
            public int nextInt()  {…};
            public long nextLong()  {…};
            public float nextFloat()  {…};
            public byte[] nextBytes()  {…};
            public String nextString()  {…};
            public Date nextDate()  {…};
            public long firstPosition()  {…};
            public long lastPosition()  {…};
            public long nextPosition()  {…};
            public boolean nextTile()  {…};
            public int elemSize()  {…};
            public Object tileItems()  {…};

            public Sequence.Type type()  {…};
            static native public boolean isRLE()  {…};
            public int itemRepeatCount(int i)  {…};
            public SequenceIterator rleDecode()  {…};
            public void reset()  {…};

            public void close()  {…};

            // Top Operations
            public SequenceIterator topMax(int top)   {…};
            public SequenceIterator topMin(int top)   {…};
            public SequenceIterator topPosMax(int top)   {…};
            public SequenceIterator topPosMin(int top)   {…};

            // Unary Operations
            public SequenceIterator abs()  {…};
            public SequenceIterator neq()   {…};
            public SequenceIterator match(String pattern)  {…};

            // Binary Operations
            public SequenceIterator add(SequenceIterator other)  {…};
            public SequenceIterator sub(SequenceIterator other)  {…};
            public SequenceIterator div(SequenceIterator other)  {…};
            public SequenceIterator mul(SequenceIterator other)  {…};
            public SequenceIterator mod(SequenceIterator other)  {…};
            public SequenceIterator max(SequenceIterator other)  {…};
            public SequenceIterator min(SequenceIterator other)  {…};

            // Comparison_Operators
            public SequenceIterator eq(SequenceIterator other)  {…};
            public SequenceIterator ne(SequenceIterator other)  {…};
            public SequenceIterator lt(SequenceIterator other)  {…};
            public SequenceIterator gt(SequenceIterator other)  {…};
            public SequenceIterator le(SequenceIterator other)  {…};
            public SequenceIterator ge(SequenceIterator other)  {…};

            // Logical Operators
            public SequenceIterator and(SequenceIterator other)  {…};
            public SequenceIterator or(SequenceIterator other)  {…};
            public SequenceIterator xor(SequenceIterator other)  {…};
            public SequenceIterator not()  {…};

            // Collapse Operations
            public SequenceIterator wsum(SequenceIterator weights)  {…};
            public SequenceIterator wavg(SequenceIterator weights)  {…};
            public SequenceIterator cov(SequenceIterator other)  {…};
            public SequenceIterator corr(SequenceIterator other)  {…};

            // Conditional Operations
            public SequenceIterator iif(SequenceIterator then,
                SequenceIterator otherwise, boolean lazy)   {…};
            public SequenceIterator filter(SequenceIterator cond)   {…};
            public SequenceIterator filterPos()   {…};

            // Grand Aggregate
            public SequenceIterator aggCount()   {…};

            public SequenceIterator aggMax()   {…};

            public SequenceIterator aggMin()   {…};

            public SequenceIterator aggSum()   {…};

            public SequenceIterator aggPrd()   {…};

            public SequenceIterator aggAvg()   {…};

            public SequenceIterator aggVar()   {…};
            public SequenceIterator aggDev()   {…};
            public SequenceIterator aggVarSamp()   {…};
            public SequenceIterator aggDevSamp()   {…};
            public SequenceIterator aggApproxDC()   {…};
            public SequenceIterator aggApproxHashDC()   {…};
            public SequenceIterator aggMinMax()   {…};

            // Group-By Aggregate
            public SequenceIterator groupAggWavg(SequenceIterator weight, SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggMax(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggMin(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggSum(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggAvg(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggVar(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggDev(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggVarSamp(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggDevSamp(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggFirst(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggLast(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggCount()   {…};
            public SequenceIterator groupAggApproxDC(SequenceIterator groupBy)   {…};
            public SequenceIterator groupAggApproxHashDC(SequenceIterator groupBy)   {…};

            // Grid Aggregate
            public SequenceIterator gridAggMax(int interval)   {…};
            public SequenceIterator gridAggMin(int interval)   {…};
            public SequenceIterator gridAggSum(int interval)   {…};
            public SequenceIterator gridAggAvg(int interval)   {…};
            public SequenceIterator gridAggVar(int interval)   {…};
            public SequenceIterator gridAggDev(int interval)   {…};
            public SequenceIterator gridAggVarSamp(int interval)   {…};
            public SequenceIterator gridAggDevSamp(int interval)   {…};

            // Window Aggregate
            public SequenceIterator windowAggMax(int interval)   {…};
            public SequenceIterator windowAggMin(int interval)   {…};
            public SequenceIterator windowAggSum(int interval)   {…};
            public SequenceIterator windowAggAvg(int interval)   {…};
            public SequenceIterator windowAggVar(int interval)   {…};
            public SequenceIterator windowAggDev(int interval)   {…};
            public SequenceIterator windowAggVarSamp(int interval)   {…};
            public SequenceIterator windowAggDevSamp(int interval)   {…};
            public SequenceIterator windowAggEma(int period)   {…};
            public SequenceIterator windowAggAtr(int period)   {…};

            // Hash Aggregate
            public GroupByResult hashAggMax(SequenceIterator groupBy, int nGroups)   {…};
            public GroupByResult hashAggMin(SequenceIterator groupBy, int nGroups)   {…};
            public GroupByResult hashAggSum(SequenceIterator groupBy, int nGroups)   {…};
            public GroupByResult hashAggAvg(SequenceIterator groupBy, int nGroups)   {…};
            public GroupByResult hashAggCount(int nGroups)   {…};
            public GroupByResult hashAggApproxdc(SequenceIterator groupBy, int nGroups)   {…};
            public GroupByResult hashAggDistinctCount(SequenceIterator groupBy, int nGroups, int nPairs)   {…};
            public GroupByResult hashAggDupCount(SequenceIterator groupBy, int nGroups, int nPairs, int minOccurrences)   {…};

            // Cumulative Aggregate
            public SequenceIterator cumAggMax()   {…};
            public SequenceIterator cumAggMin()   {…};
            public SequenceIterator cumAggSum()   {…};
            public SequenceIterator cumAggPrd()   {…};
            public SequenceIterator cumAggAvg()   {…};
            public SequenceIterator cumAggVar()   {…};
            public SequenceIterator cumAggDev()   {…};
            public SequenceIterator cumAggVarSamp()   {…};
            public SequenceIterator cumAggDevSamp()   {…};

            // Sequence Manipulator Operations
            public static SequenceIterator parse(String val, Sequence.Type type) {…};
            public SequenceIterator map(SequenceIterator positions)  {…};
            public SequenceIterator[] tee()
            public static SequenceIterator constant(double val, Sequence.Type type)  {…};
            public static SequenceIterator constant(long val, Sequence.Type type)  {…};
            public static SequenceIterator constant(byte[] val, Sequence.Type type)  {…};
            public SequenceIterator concat(SequenceIterator tail)  {…};
            public SequenceIterator cat(SequenceIterator other)  {…};
            public SequenceIterator unique()   {…};
            public SequenceIterator normalize()   {…};
            public SequenceIterator thin(long origin, long step)   {…};
            public SequenceIterator limit(long from, long till)   {…};
            public SequenceIterator reverse()   {…};
            public SequenceIterator diff()   {…};
            public SequenceIterator trend()   {…};
            public SequenceIterator repeat(int count)   {…};
            public SequenceIterator stretch(SequenceIterator ts1, SequenceIterator ts2, long filler)   {…};
            public SequenceIterator stretch(SequenceIterator ts1, SequenceIterator ts2, double filler)   {…};
            public SequenceIterator stretch0(SequenceIterator ts1, SequenceIterator ts2, long filler)   {…};
            public SequenceIterator stretch0(SequenceIterator ts1, SequenceIterator ts2, double filler)   {…};
            public SequenceIterator asofJoin(SequenceIterator ts1, SequenceIterator ts2)   {…};
            public SequenceIterator cross(int firstCrossDirection)   {…};
            public SequenceIterator extrema(int firstExtremum)   {…};
            public SequenceIterator hash()   {…};

            public SequenceIterator hash(SequenceIterator other)   {…};

            // Conversion
            public SequenceIterator cast(Sequence.Type type)   {…};

            // Miscellaneous
            public SequenceIterator histogram(long low, long high, int nIntervals)   {…};
            public SequenceIterator histogram(double low, double high, int nIntervals)   {…};
            public void sort(Object arr, long[] permutation, Sequence.Order order)   {…};

        };

### Methods

`SequenceIterator(long hnd)` | Constructor: return a SequenceIterator instance
`get(), next(), nextInt(), nextLong(), nextFloat(), nextDouble(), nextBytes(), nextString(), nextDate(), firstPosition(), lastPosition(), nextPosition(), nextTile(), elemSize(), tileSize(), type(), isRLE(), itemRepeatCount(), rleDecode(), reset(), close()` | Iterator methods are used to extract and iterate the object's sequence elements, determine the sequence element type, size and position within the iterator's sequence, determine the sequence tile size, and, for RLE encoded sequences, determine the repeat count or decode the RLE sequence to a non-RLE sequence
`topMax(), topMin(), topPosMax(), topPosMin()` | Top methods produce result sequences of the top `n` maximum or minimum elements or their positions
`abs(), neg(), match()` | Unary methods returning the sequence of absolute values, negatives or a boolean sequence indicating the elements that match the given string
`add(), sub(), mul(), div(), mod(), max(), min()` | Binary methods returning the sequence of results from performing the indicated operations
`eq(), ne(), gt(), ge(), lt() le()` | Comparison methods returning a boolean result sequence by applying the specified comparison operator on the object's sequence and the corresponding elements in the input sequence
`not(), and(), or(), xor()` | Logical methods returning a boolean result sequence by applying the specified operation on the object's sequence and the corresponding elements in the input sequence
`wsum(), wavg(), cov(), corr()` | Collapse methods returning a boolean result sequence by applying the specified operation on the object's sequence and the corresponding elements in the input sequence
`iif(), filter(), filterPos()` | Conditional methods returning a boolean result sequence by applying the specified operation on the object's sequence and the corresponding elements in the input sequence
`aggCount(), aggMax(), aggMin(), aggSum(), aggPrd(), aggAvg(), aggVar(), aggVarSamp(), aggDev(), aggDevSamp(), aggApproxDC(), aggApproxHashDC(), aggMinMax()` | Grand Aggregate methods returning a `double` SequenceIterator the first element of which is the operation result
`groupAggCount(), groupAggMax(), groupAggMin(), groupAggSum(), groupAggPrd(), groupAggAvg(), groupAggVar(), groupAggVarSamp(), groupAggDev(), groupAggDevSamp(), groupAggApproxDC(), groupAggApproxHashDC(), groupAggWavg()` | Group-By Aggregate methods produce a result sequence containing the calculated aggregate for each group
`gridAggMax(), gridAggMin(), gridAggSum(), gridAggPrd(), gridAggAvg(), gridAggVar(), gridAggVarSamp(), gridAggDev(), gridAggDevSamp()` | Grid Aggregate methods produce a result sequence containing the calculated aggregate for each interval
`windowAggMax(), windowAggMin(), windowAggSum(), windowAggPrd(), windowAggAvg(), windowAggVar(), windowAggVarSamp(), windowAggDev(), windowAggDevSamp(), windowAggEma(), windowAggAtr()` | Window Aggregate methods produce a result sequence the calculated aggregate for each window. For the `windowAggEma()`and `windowAggAtr()` methods, the first element of the sequence is the operation result
`hashAggCount(), hashAggMax(), hashAggMin(), hashAggSum(), hashAggAvg(), hashAggApproxdc(), hashAggDistinctCount(), hashAggDupCount()` | Hash Aggregate methods produce a GroupByResult for the grouping values which can then be converted to a SequenceIterator by calling method `getIterator()`
`cumAggMax(), cumAggMin(), cumAggSum(), cumAggPrd(), cumAggAvg(), cumAggVar(), cumAggVarSamp(), cumAggDev(), cumAggDevSamp()` | Cumulative Aggregate methods produce a result sequence in which the value of each element is the result of the specified operation on all of the preceding elements.
`parse(), map(), tee(), constant(), concat(), cat(), unique(), normalize(), thin(), limit(), reverse(), diff(), trend(), repeat() stretch(), stretch0(), asOfJoin(), cross(), extrema(), hash()` | Manipulator methods produce a variety of different sequence results
`cast()` | Conversion methods produce a sequence result of the desired type
`histogram(), sort()` | Miscellaneous methods produce a sequence result representing a histogram of the input sequence values, or sort the sequence