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 request: add .Clear method #55

Open
novadev94 opened this issue Jan 14, 2025 · 1 comment
Open

feature request: add .Clear method #55

novadev94 opened this issue Jan 14, 2025 · 1 comment

Comments

@novadev94
Copy link

Currently, it's impossible to clear the OrderedMap keeping its capacity.

A simple implementation would be:

func (l *list[K, V]) Clear() {
	l.root = Element[K, V]{} // just in case K & V are pointer types
}

func (m *OrderedMap[K, V]) Clear() {    
	clear(m.kv)
	m.ll.Clear()
}
@elliotchance
Copy link
Owner

Happy to accept a PR for this. I see clear() was introduced in Go 1.21, so for backwards compatibility it shouldn't use that function in this implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants