public bool MoveNext()
 {
     if (current == null || first == null)
     {
         current = first;
         return(current != null);
     }
     current = current.next;
     return(current != null);
 }
        public void Add(T item)
        {
            var newIt = new RestrictedQueueContainer <T>(item)
            {
                prev = null, next = null
            };

            if (length == 0 || maxQueueLength == 1)
            {
                first = newIt;
                last  = newIt;
                if (length < maxQueueLength)
                {
                    length++;
                }
                return;
            }

            if (length == 1)
            {
                first.next = newIt;
                newIt.prev = first;
                last       = newIt;
                length++;
                return;
            }

            if (length == maxQueueLength)
            {
                first.next.prev = null;
                first           = first.next;
            }
            else
            {
                length++;
            }

            last.next  = newIt;
            newIt.prev = last;
            last       = newIt;
        }
        public T DequeueLast()
        {
            if (last == null)
            {
                return(default(T));
            }
            if (length == 1)
            {
                var item = last.item;
                last    = null;
                first   = null;
                current = null;
                length  = 0;
                return(item);
            }

            var lastValue = last.item;
            var prevLast  = last.prev;

            prevLast.next = null;
            last          = prevLast;
            length--;
            return(lastValue);
        }
 public void Clear()
 {
     length = 0;
     first  = null;
     last   = null;
 }
 public void Reset()
 {
     current = null;
 }
 public void Dispose()
 {
     length = 0;
     first  = null;
     last   = null;
 }