Exemplo n.º 1
0
        public Document_V2 GetDocument()
        {
            Document_V2 doc = _documentList.First.Value;

            _documentList.RemoveFirst();
            return(doc);
        }
Exemplo n.º 2
0
 public void AddDocument(Document_V2 d)
 {
     if (d == null)
     {
         throw new ArgumentNullException("d");
     }
     AddDocumentToPriorityNode(d, d.Priority);
 }
Exemplo n.º 3
0
 private void AddDocumentToPriorityNode(Document_V2 doc, int priority)
 {
     if (priority > 9 || priority < 0)
     {
         throw new ArgumentException("等级必须为0~9");
     }
     if (_priorityNodes[priority].Value == null)
     {
         --priority;
         if (priority >= 0)
         {
             AddDocumentToPriorityNode(doc, priority);
         }
         else
         {
             _documentList.AddLast(doc);
             _priorityNodes[doc.Priority] = _documentList.Last;
         }
         return;
     }
     else
     {
         LinkedListNode <Document_V2> prioNode = _priorityNodes[priority];
         if (priority == doc.Priority)
         {
             _documentList.AddAfter(prioNode, doc);
             _priorityNodes[doc.Priority] = prioNode.Next;
         }
         else
         {
             LinkedListNode <Document_V2> firstPrioNode = prioNode;
             while (firstPrioNode.Previous != null &&
                    firstPrioNode.Previous.Value.Priority == prioNode.Value.Priority)
             {
                 firstPrioNode = prioNode.Previous;
                 prioNode      = firstPrioNode;
             }
             _documentList.AddBefore(firstPrioNode, doc);
             _priorityNodes[doc.Priority] = firstPrioNode.Previous;
         }
     }
 }