Ejemplo n.º 1
0
        /// <summary>
        /// 返回编号队员
        /// </summary>
        /// <param name="curNo">0,1,2...</param>
        /// <returns></returns>
        public T RtnMember(int idNo)
        {
            try
            {
                if (_count == 0 || idNo > _count - 1)
                {
                    return(default(T));
                }

                if (idNo == 0)   //队头
                {
                    return(_head._value);
                }
                else if (idNo == _count - 1) //队尾
                {
                    return(_tail._value);
                }
                else
                {
                    CQueueNode <T> node = _head.back;
                    for (int i = 1; i < idNo; i++)
                    {
                        node = node.back;
                    }
                    return(node._value);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 出队
 /// </summary>
 public T DeQueue()
 {
     if (count != 0)
     {
         T queue = _head._value;
         if (_head == _tail)
         {
             _count--;
             return(queue);
         }
         _head = _head.back;
         _count--;
         return(queue);
     }
     return(default(T));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 入队
 /// </summary>
 /// <param name="newValue"></param>
 public void EnQueue(T sender)
 {
     try
     {
         CQueueNode <T> newNode = new CQueueNode <T>(sender);
         if (count == 0)
         {
             _head = newNode;
             _tail = newNode;
         }
         else
         {
             _tail.back   = newNode;
             newNode.fore = _tail;
             _tail        = newNode;
         }
         _count++;
     }
     catch (Exception)
     {
         throw;
     }
 }