Example #1
0
        /// <summary>
        /// (non-Javadoc)
        /// see com.browseengine.bobo.api.IntFacetIterator#nextInt()
        /// </summary>
        /// <returns></returns>
        public override int NextInt()
        {
            if (!HasNext())
            {
                throw new IndexOutOfRangeException("No more facets in this iteration");
            }

            IntIteratorNode node = _queue.Top();

            _facet = node.CurFacet;
            int next = TermIntList.VALUE_MISSING;

            count = 0;
            while (HasNext())
            {
                node = _queue.Top();
                next = node.CurFacet;
                if ((next != TermIntList.VALUE_MISSING) && (next != _facet))
                {
                    return(_facet);
                }
                count += node.CurFacetCount;
                if (node.Fetch(1))
                {
                    _queue.UpdateTop();
                }
                else
                {
                    _queue.Pop();
                }
            }
            return(TermIntList.VALUE_MISSING);
        }
Example #2
0
        /// <summary>
        /// This version of the next() method applies the minHits from the facet spec before returning the facet and its hitcount
        /// </summary>
        /// <param name="minHits">the minHits from the facet spec for CombinedFacetAccessible</param>
        /// <returns>The next facet that obeys the minHits</returns>
        public override string Next(int minHits)
        {
            int qsize = _queue.Size();

            if (qsize == 0)
            {
                _facet = TermIntList.VALUE_MISSING;
                count  = 0;
                return(null);
            }

            IntIteratorNode node = _queue.Top();

            _facet = node.CurFacet;
            count  = node.CurFacetCount;
            while (true)
            {
                if (node.Fetch(minHits))
                {
                    node = _queue.UpdateTop();
                }
                else
                {
                    _queue.Pop();
                    if (--qsize > 0)
                    {
                        node = _queue.Top();
                    }
                    else
                    {
                        // we reached the end. check if this facet obeys the minHits
                        if (count < minHits)
                        {
                            _facet = TermIntList.VALUE_MISSING;
                            count  = 0;
                            return(null);
                        }
                        break;
                    }
                }
                int next = node.CurFacet;
                if (next != _facet)
                {
                    // check if this facet obeys the minHits
                    if (count >= minHits)
                    {
                        break;
                    }
                    // else, continue iterating to the next facet
                    _facet = next;
                    count  = node.CurFacetCount;
                }
                else
                {
                    count += node.CurFacetCount;
                }
            }
            return(Format(_facet));
        }
Example #3
0
 public CombinedIntFacetIterator(IList <IntFacetIterator> iterators, int minHits)
     : this(iterators.Count)
 {
     _iterators = iterators;
     foreach (IntFacetIterator iterator in iterators)
     {
         IntIteratorNode node = new IntIteratorNode(iterator);
         if (node.Fetch(minHits))
         {
             _queue.Add(node);
         }
     }
     _facet = TermIntList.VALUE_MISSING;
     count  = 0;
 }
 public CombinedIntFacetIterator(IList<IntFacetIterator> iterators, int minHits)
     : this(iterators.Count)
 {
     _iterators = iterators;
     foreach (IntFacetIterator iterator in iterators)
     {
         IntIteratorNode node = new IntIteratorNode(iterator);
         if (node.Fetch(minHits))
             _queue.Add(node);
     }
     _facet = TermIntList.VALUE_MISSING;
     count = 0;
 }