Exemplo n.º 1
0
        public void Enqueue(int priority, NAW naw)
        {
            NawQueueLinkedList queue;

            if (_priorityQueue.ContainsKey(priority))
            {
                _priorityQueue.TryGetValue(priority, out queue);
                queue.Enqueue(naw);
                _priorityQueue.Remove(priority);
                _priorityQueue.Add(priority, queue);
            }
            else
            {
                queue = new NawQueueLinkedList();
                queue.Enqueue(naw);
                _priorityQueue.Add(priority, queue);
            }
        }
        public void Enqueue(int priority, NAW naw)
        {
            if (priority < 0)
            {
                return;
            }

            NawQueueLinkedList list;

            if (_priorityQueue.ContainsKey(priority))
            {
                list = new NawQueueLinkedList();
                _priorityQueue.TryGetValue(priority, out list);
                list.Enqueue(naw);
            }
            else
            {
                list = new NawQueueLinkedList();
                list.Enqueue(naw);
                _priorityQueue.Add(priority, list);
            }
        }