Esempio n. 1
0
        // Invariant: a[i] < a[i+1] for i > item
        // returns flase is head of the list was moved & as a result consistancy of list depends on head consistancy.
        private bool SiftItem(int item)
        {
            Debug.Assert(firstNotEmpty <= item && item < arr.Length);
            ResettableIterator it = arr[item];

            while (item + 1 < arr.Length)
            {
                ResettableIterator itNext = arr[item + 1];
                Debug.Assert(it.Current != null && itNext.Current != null);
                XmlNodeOrder order = Query.CompareNodes(it.Current, itNext.Current);
                if (order == XmlNodeOrder.Before)
                {
                    break;
                }
                if (order == XmlNodeOrder.After)
                {
                    arr[item] = itNext;
                    //arr[item + 1] = it;
                    item++;
                }
                else
                { // Same
                    arr[item] = it;
                    if (!Advance(item))
                    {
                        return(false);
                    }
                    it = arr[item];
                }
            }
            arr[item] = it;
            return(true);
        }
Esempio n. 2
0
 // returns false is iterator at pos reached it's end & as a result head of the array may be moved
 private bool Advance(int pos)
 {
     if (!arr[pos].MoveNext())
     {
         if (firstNotEmpty != pos)
         {
             ResettableIterator empty = arr[pos];
             Array.Copy(arr, firstNotEmpty, arr, firstNotEmpty + 1, pos - firstNotEmpty);
             arr[firstNotEmpty] = empty;
         }
         firstNotEmpty++;
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
 protected ResettableIterator(ResettableIterator other)
 {
     base.count = other.count;
 }