示例#1
0
        public void Enqueue(T t, TPriority priority)
        {
            if (Count == Heap.Length)
            {
                ExpandHeap();
            }

            Heap[Count] = new ValuePriority <T, TPriority>(t, priority);
            BubbleUp(Count);
            Count++;
        }
示例#2
0
        public void UpdateValueFromIndex(ValuePriorityIndex pIndex, TPriority newPriority)
        {
            if (pIndex.Version != _version)
            {
                throw new InvalidOperationException("The priority queue was modified after the index was retrieved.");
            }

            int index = pIndex.Index;

            _heap[index] = new ValuePriority <T, TPriority>(_heap[index].Value, newPriority);
            _version++;
        }
示例#3
0
 public bool Equals(ValuePriority <T, TPriority> other)
 {
     return(Value.Equals(other.Value) && Priority.Equals(other.Priority));
 }