Пример #1
0
        public int CompareTo(PriorityQueueNode <TKey, TPriority> other)
        {
            if (other == null)
            {
                return(-1);
            }

            return(this.Priority.CompareTo(other.Priority));
        }
Пример #2
0
        /// <summary>
        /// Enqueue the specified key, value and priority.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="priority">Priority.</param>
        public void Enqueue(TKey key, TPriority priority)
        {
            var newNode = new PriorityQueueNode <TKey, TPriority>(key, priority);

            _heap.Add(newNode);

            if (_keys.ContainsKey(key))
            {
                _keys[key] += 1;
            }
            else
            {
                _keys.Add(key, 1);
            }
        }