Skip to content

Add range variants of FindMin() and DeleteMin() #94

@vslee

Description

@vslee

Description

SortedDictionaryBase<K,V> currently has FindMin/Max() and DeleteMin/Max(). These work on single items, but it would be useful to have range variants to efficiently get multiple items at once.

Solution

Add variants, such as FindMinRange(int numItems) and DeleteMinRange(int numItems).

Describe alternatives you've considered

For DeleteMinRange(), one could call DeleteMin() multiple times. But this is likely is not as efficient as a range implementation which can perform the entire operation at once.
For FindMinRange(), calling FindMin() multiple times wouldn't work. One could workaround this by calling RangeAll() and iterating through that. But that seems roundabout and is not immediately obvious.
There are also the RangeFrom(K bot) and RangeTo(K top), but those don't allow specifying numItems as a parameter. 

Additional context

Eventually, these variants could be added to PriorityQueue<T> as well. But implementing it in IntervalHeap<T> will take some effort. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions