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;
        }
 public int CompareTo(PrioritizedItem <TPriority, TItem> other)
 {
     return(Priority.CompareTo(other.Priority));
 }
 public PriorityHeap(int capacity = DEFAULT_CAPACITY)
 {
     _buffer     = new PrioritizedItem <TPriority, TItem> [capacity];
     _enumerator = new Enumerator();
     Clear();
 }