/// <summary>
 /// (non-Javadoc)
 /// see java.util.Iterator#next()
 /// </summary>
 /// <returns></returns>
 public override string Next()
 {
     if ((_index >= 0) && (_index >= _countLengthMinusOne))
     {
         throw new IndexOutOfRangeException("No more facets in this iteration");
     }
     _index++;
     _facet = _valList.GetPrimitiveValue(_index);
     count  = _count.Get(_index);
     return(_valList.Get(_index));
 }
            private void Aggregate()
            {
                if (_isAggregated)
                {
                    return;
                }

                _isAggregated = true;

                int startIdx = _valArray.IndexOf(_start);

                if (startIdx < 0)
                {
                    startIdx = -(startIdx + 1);
                }

                int endIdx = _valArray.IndexOf(_end);

                if (endIdx < 0)
                {
                    endIdx = -(endIdx + 1);
                }

                BigSegmentedArray baseCounts = _baseCollector.GetCountDistribution();

                if (_start is long)
                {
                    long         start    = Convert.ToInt64(_start);
                    long         unit     = Convert.ToInt64(_unit);
                    TermLongList valArray = (TermLongList)_valArray;
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        long val = valArray.GetPrimitiveValue(i);
                        int  idx = (int)((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
                else if (_start is int)
                {
                    int         start    = Convert.ToInt32(_start);
                    int         unit     = Convert.ToInt32(_unit);
                    TermIntList valArray = (TermIntList)_valArray;
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        int val = valArray.GetPrimitiveValue(i);
                        int idx = ((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
                else
                {
                    double start = Convert.ToDouble(_start);
                    double unit  = Convert.ToDouble(_unit);
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        double val = (double)_valArray.GetRawValue(i);
                        int    idx = (int)((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
            }