Example #1
0
            private bool TryMove(Predicate <EnumeratorT> Predicate = null, bool Decueue = false)
            {
                if (IsDisposed)
                {
                    throw new ObjectDisposedException(GetType().ToString());
                }

                lock (rootEnumerable.RootQueue.sync)
                {
                    var StartNode = currentNode;

                    //CurrentNode.Next should never be null
                    while (!currentNode.Next.Equals(rootEnumerable.RootQueue.linkNode))
                    {
                        rootEnumerable.Bookmark = currentNode = currentNode.Next;

                        if (Predicate?.Invoke(currentNode.Item) ?? true)
                        {
                            StartNode.EnumeratorRelease();
                            currentNode.EnumeratorHold();
                            if (Decueue)
                            {
                                rootEnumerable.Bookmark = currentNode.Next;
                                currentNode.Remove();
                                rootEnumerable.RootQueue.Count--;
                            }
                            return(true);
                        }
                    }
                }
                return(false);
            }
 //Optimized version of WHERE.
 public IEnumerable <EnumerableT> Where(Predicate <EnumerableT> Predicate)
 {
     using (var Enumerator = new RealtimeQueue <EnumerableT> .RealtimeQueueEnumerator <EnumerableT>(this, Bookmark))
     {
         if (Enumerator.MoveWhere(Predicate))
         {
             yield return(Enumerator.Current);
         }
     }
 }
 public IEnumerable <EnumerableT> Decueue()
 {
     using (var Enumerator = new RealtimeQueue <EnumerableT> .RealtimeQueueEnumerator <EnumerableT>(this, Bookmark))
     {
         if (Enumerator.MoveWhere(null, true))
         {
             yield return(Enumerator.Current);
         }
     }
 }
 IEnumerator IEnumerable.GetEnumerator()
 {
     using (var Enumerator = new RealtimeQueue <EnumerableT> .RealtimeQueueEnumerator <EnumerableT>(this, Bookmark))
     {
         while (Enumerator.MoveNext())
         {
             yield return(Enumerator.Current);
         }
     }
 }
Example #5
0
 public RealtimeQueueEnumerator(RealtimeQueueEnumerable <EnumeratorT> RootEnumerable, object Bookmark)
 {
     rootEnumerable = RootEnumerable;
     timeout        = RootEnumerable.Timeout;
     if (useBookmark = RootEnumerable.BookmarkEnumeration && Bookmark != null)
     {
         if (!(Bookmark is RealtimeQueue <EnumeratorT> .RealtimeQueueNode))
         {
             throw new ArgumentException($"Enumerator was initialized with a type other than {typeof(RealtimeQueue<EnumeratorT>.RealtimeQueueNode).ToString()}");
         }
         currentNode = Bookmark as RealtimeQueue <EnumeratorT> .RealtimeQueueNode;
     }
     else
     {
         currentNode = rootEnumerable.RootQueue.linkNode;
     }
     TimeoutClock.Reset();
     TimeoutClock.Start();
 }
Example #6
0
 public RealtimeQueueEnumerator(RealtimeQueue <T> Root, int Timeout)
 {
     rootList     = Root;
     this.Timeout = Timeout;
     Reset();
 }
Example #7
0
 public RealtimeQueueEnumerable(RealtimeQueue <T> Root, int Timeout = 0)
 {
     rootList = Root;
     timeout  = Timeout;
 }
 public RealtimeQueueNode(RealtimeQueue <T> Root)
 {
     rootList = Root;
 }
 internal RealtimeQueueNode(RealtimeQueue <T> Root)
 {
     rootList = Root;
 }
 public RealtimeQueueEnumerable(RealtimeQueue <EnumerableT> RootQueue, int Timeout, bool BookmarkEnumeration)
 {
     this.RootQueue           = RootQueue;
     this.Timeout             = Timeout;
     this.BookmarkEnumeration = BookmarkEnumeration;
 }