-
Notifications
You must be signed in to change notification settings - Fork 16
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
Keep track of number of elements for efficient len() #32
Comments
Looking at this, it seems like this could be used to speed up other operations too. For example, |
jonhoo
added a commit
to jonhoo/vec-map
that referenced
this issue
Apr 12, 2017
This allows much more efficient versions of len() and is_empty(), and also enables ExactSizeIterator to be implemented to VecMap's iterators. Fixes contain-rs#32
jonhoo
added a commit
to jonhoo/vec-map
that referenced
this issue
Apr 12, 2017
This allows much more efficient versions of len() and is_empty(), and also enables ExactSizeIterator to be implemented for VecMap's iterators. Fixes contain-rs#32
jonhoo
added a commit
to jonhoo/vec-map
that referenced
this issue
Apr 13, 2017
This allows much more efficient versions of len() and is_empty(), and also enables ExactSizeIterator to be implemented for VecMap's iterators. Fixes contain-rs#32
camsteffen
pushed a commit
to camsteffen/vec-map
that referenced
this issue
May 14, 2017
This allows much more efficient versions of len() and is_empty(), and also enables ExactSizeIterator to be implemented for VecMap's iterators. Fixes contain-rs#32
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
VecMap::len()
takesO(highest index)
time to compute every time (same goes forVecMap::is_empty()
. It'd be nice ifVecMap
instead kept track of the number ofSome
it has, and just use this value inlen()
andis_empty()
. It would add ausize
to theVecMap
struct, but this seems negligible compared to the performance gains of doing so. I'll submit a PR shortly which you can merge if you feel like this would be a useful addition :)The text was updated successfully, but these errors were encountered: