Esempio n. 1
0
        public void Insert(TPriority priority, TItem item)
        {
            EnsureCapacity();

            for (var index = 0; index < Count; index++)
            {
                var heapItem = _buffer[index];

                if (!heapItem.Item.Equals(item))
                {
                    continue;
                }

                _buffer[index] = new PrioritizedItem <TPriority, TItem>(priority, item);
                return;
            }

            _buffer[Count++]  = new PrioritizedItem <TPriority, TItem>(priority, item);
            _maxPriorityIndex = -1;
        }
Esempio n. 2
0
 public int CompareTo(PrioritizedItem <TPriority, TItem> other)
 {
     return(Priority.CompareTo(other.Priority));
 }
Esempio n. 3
0
 public PriorityHeap(int capacity = DEFAULT_CAPACITY)
 {
     _buffer     = new PrioritizedItem <TPriority, TItem> [capacity];
     _enumerator = new Enumerator();
     Clear();
 }