示例#1
0
文件: Text.cs 项目: ChazZeromus/gscc
            public T Read(Boolean store = false)
            {
                if (!store && !StoresEmpty)
                {
                    isStored = true;
                    //Returning a backing store version requires that prev be valid
                    if (PrevBeforeStore != null)
                    {
                        Prev            = PrevBeforeStore;
                        PrevBeforeStore = default(T);
                    }
                    else
                    {
                        Prev = Current;
                    }
                    Current         = QPk.Dequeue();
                    Current.isStore = true;
                    if (BackingEmpty)
                    {
                        Stores.Pop();
                    }
                    return(Current);
                }
                else
                {
                    isStored = false;
                }

                Prev = Current;

                Current = ReadNext();

                if (store)
                {
                    /*if (Dirty)
                     *      throw new Exception("Cannot store the read object because backing store was not empty.");*/
                    if (StoresEmpty)
                    {
                        NewBacking(null);
                    }
                    if (BackingEmpty)
                    {
                        PrevBeforeStore = Prev;
                    }
                    QPk.Enqueue(Current);
                }

                return(Current);
            }
示例#2
0
文件: Text.cs 项目: ChazZeromus/gscc
 public void DiscardBackingStore(int count)
 {
     if (!StoresEmpty && count > QPk.Count)
     {
         throw new Exception("Attempted to pop off more than the size of the current backing!");
     }
     while (!StoresEmpty && !BackingEmpty && count-- > 0)
     {
         QPk.Dequeue();
     }
     if (!StoresEmpty && BackingEmpty)
     {
         Stores.Pop();
     }
 }