/// <summary> /// Returns but does not remove the key-value pair in front of the Queue /// </summary> /// <returns></returns> public override (K, V) Min() { if (IsEmpty()) { throw new InvalidOperationException("The Priority Queue is empty"); } PositionalList <Item> .Position p = data.First(); Item item = p.element(); return(item.key, item.value); }
/// <summary> /// Returns the position of the minimum key /// </summary> /// <returns></returns> public PositionalList <Item> .Position FindMin() { if (IsEmpty()) { throw new InvalidOperationException("The Priority Queue is empty"); } PositionalList <Item> .Position small = data.First(); PositionalList <Item> .Position walk = data.After(small); while (walk != null) { if (walk.element() < small.element()) { small = walk; } walk = data.After(walk); } return(small); }