public override float NextSingle()
        {
            if (!HasNext())
            {
                throw new IndexOutOfRangeException("No more facets in this iteration");
            }

            SingleIteratorNode node = m_queue.Top;

            m_facet = node.CurFacet;
            float next = TermSingleList.VALUE_MISSING;

            m_count = 0;
            while (HasNext())
            {
                node = m_queue.Top;
                next = node.CurFacet;
                if ((next != TermSingleList.VALUE_MISSING) && (next != m_facet))
                {
                    return(m_facet);
                }
                m_count += node.CurFacetCount;
                if (node.Fetch(1))
                {
                    m_queue.UpdateTop();
                }
                else
                {
                    m_queue.Pop();
                }
            }
            return(TermSingleList.VALUE_MISSING);
        }
        /// <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 = m_queue.Count;

            if (qsize == 0)
            {
                m_facet = TermSingleList.VALUE_MISSING;
                m_count = 0;
                return(null);
            }

            SingleIteratorNode node = m_queue.Top;

            m_facet = node.CurFacet;
            m_count = node.CurFacetCount;
            while (true)
            {
                if (node.Fetch(minHits))
                {
                    node = m_queue.UpdateTop();
                }
                else
                {
                    m_queue.Pop();
                    if (--qsize > 0)
                    {
                        node = m_queue.Top;
                    }
                    else
                    {
                        // we reached the end. check if this facet obeys the minHits
                        if (m_count < minHits)
                        {
                            m_facet = TermSingleList.VALUE_MISSING;
                            m_count = 0;
                            return(null);
                        }
                        break;
                    }
                }
                float next = node.CurFacet;
                if (next != m_facet)
                {
                    // check if this facet obeys the minHits
                    if (m_count >= minHits)
                    {
                        break;
                    }
                    // else, continue iterating to the next facet
                    m_facet = next;
                    m_count = node.CurFacetCount;
                }
                else
                {
                    m_count += node.CurFacetCount;
                }
            }
            return(Format(m_facet));
        }
 public CombinedSingleFacetIterator(IList <SingleFacetIterator> iterators, int minHits)
     : this(iterators.Count)
 {
     m_iterators = iterators;
     foreach (SingleFacetIterator iterator in iterators)
     {
         SingleIteratorNode node = new SingleIteratorNode(iterator);
         if (node.Fetch(minHits))
         {
             m_queue.Add(node);
         }
     }
     m_facet = TermSingleList.VALUE_MISSING;
     m_count = 0;
 }