Beispiel #1
0
 /// <summary>
 /// Stored the current item into the current backing. Creates a new backing
 /// if one doesn't already exist.
 /// </summary>
 /// <param name="id">ID of the new backing.</param>
 public void Enqueue(String id = null)
 {
     if (StoresEmpty)
     {
         NewBacking(id);
     }
     QPk.Enqueue(Current);
     PrevBeforeStore = Prev;
 }
Beispiel #2
0
 /// <summary>
 /// Empties queue into current backing, a new one
 /// if it doesn't already exist.
 /// </summary>
 /// <param name="newQueue"></param>
 public void EnqueueNew(Queue <T> newQueue, String id = null)
 {
     if (StoresEmpty)
     {
         NewBacking(id);
     }
     while (newQueue.Count > 0)
     {
         QPk.Enqueue(newQueue.Dequeue());
     }
     PrevBeforeStore = Prev;
 }
Beispiel #3
0
            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);
            }
Beispiel #4
0
 /// <summary>
 /// Manually enqueues the current item into a new backing, all other stored reads will be stored
 /// in that backing from now on.
 /// </summary>
 /// <param name="id">ID of the new backing.</param>
 public void StartStore(String id = null)
 {
     NewBacking(id);
     QPk.Enqueue(Current);
     PrevBeforeStore = Prev;
 }