Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add Clear() to collection types #78

Open
jnyrup opened this issue Aug 29, 2023 · 0 comments
Open

[FEATURE] Add Clear() to collection types #78

jnyrup opened this issue Aug 29, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jnyrup
Copy link

jnyrup commented Aug 29, 2023

Is your feature request related to a problem? Please describe.
When wanting to clear e.g. a FibonacciQueue there is as far as I can see no efficient way to do this.

An inefficient way is to repeatedly call dequeue until it is empty, but that causes unnecessary updates of the data structure to maintain the invariants for each call to Dequeue.

while (queue.Count > 0) // Dispose all calculation items
{
    _ = queue.Dequeue();
}

Describe the solution you'd like
BCL collection types like List<T> and Dictionary<TKey, TValue> have a Clear() method to empty them.
It would be nice for all/most QuikGraph collections to have a similar method.

The ones I have seen missing a Clear are:

  • BinaryQueue, BinaryQueue,
  • FibonacciQueue, FibonacciHeap, FibonacciHeapLinkedList
  • ForestDisjointSet

If acceptable IQueue<T> and IDisjointSet<T> could have a void Clear() added, but that is technically a breaking change if any consumers have already implemented those interfaces.

Describe alternatives you've considered

Additional context
I'd be happy to do the implementation and testing of this.

@jnyrup jnyrup added the enhancement New feature or request label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants