Unbalanced priority search pennants.
> data PSQ k p = Void | Winner k p (LTree k p) k |
Here, LLoser means that the loser stems from the left subtree.
> maxKey :: PSQ k p -> k |
Playing a match.
> play :: (Ord k, Ord p) => PSQ k p -> PSQ k p -> PSQ k p |
Note that the origin of the loser is now recorded in the constructor.
Tournament view.
> data TourView k p = Null | Single k p | PSQ k p `Play` PSQ k p |
> empty = Void |
The helper function single' constructs a singleton queue from a given key and a given priority (rather than from a given binding).
> insert b q = case tourView q of |
> minView Void = Empty |
Determining the second-best player.
> secondBest :: (Ord k, Ord p) => LTree k p -> k -> PSQ k p |
> lookup k q = case tourView q of |
> atMostRanges :: (Ord k, Ord p) => p -> (k, k) -> PSQ k p -> Sequ (Binding k p) |
> adjust f k q = case tourView q of |