/// <summary> /// Call this method to change the priority of an item. /// Calling this method on a item not in the queue will throw an exception. /// If the item is enqueued multiple times, only the first one will be updated. /// (If your requirements are complex enough that you need to enqueue the same item multiple times <i>and</i> be able /// to update all of them, please wrap your items in a wrapper class so they can be distinguished). /// O(n) /// </summary> public void UpdatePriority(T item, int priority) { lock (_queue) { try { SimpleNode updateMe = GetExistingNode(item); _queue.UpdatePriority(updateMe, priority); } catch (InvalidOperationException ex) { throw new InvalidOperationException("Cannot call UpdatePriority() on a node which is not enqueued: " + item, ex); } } }