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

Optimize 'sizeMap' #99

Open
sjakobi opened this issue Feb 20, 2017 · 4 comments
Open

Optimize 'sizeMap' #99

sjakobi opened this issue Feb 20, 2017 · 4 comments

Comments

@sjakobi
Copy link
Contributor

sjakobi commented Feb 20, 2017

I think sizeMap could be faster in the cases where either the keys or the values are of constant size.

@mgsloan
Copy link
Owner

mgsloan commented Feb 20, 2017

Not sure if it's worth the extra logic, since you still need to traverse the whole map to figure out how many members it has.

@sjakobi
Copy link
Contributor Author

sjakobi commented Feb 20, 2017

I'll write a benchmark to check.

@sjakobi
Copy link
Contributor Author

sjakobi commented Feb 21, 2017

Not sure if it's worth the extra logic, since you still need to traverse the whole map to figure out how many members it has.

Ah, I see what you mean now. Well, I think that's a downside to using mono-foldable's olength here: in contrast to IntMap and HashMap , Map actually has an O(1) size function. It's the same with the respective Set versions.

@mgsloan
Copy link
Owner

mgsloan commented Feb 23, 2017

Oh, awesome, didn't realize Map and Set had that info available!

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