Add minimum comparison element search function to array
module
#18684
Replies: 3 comments
-
How well does it work on arrays with multiple identical values? |
Beta Was this translation helpful? Give feedback.
-
Benchmark was done on array of random ints with a lot of duplications. So you can see results above |
Beta Was this translation helpful? Give feedback.
-
Another option would be to skip all the boilerplate with Yes, it is a minuscule waste of memory (always one item), but: a) V arrays are huge under the hood - making them one item bigger is no big deal. |
Beta Was this translation helpful? Give feedback.
-
Describe the feature
By @dumblob
Use Case
A faster search of an element in an array.
Proposed Solution
Example implementation
Other Information
Interesting concept, but unfortunately:
mut
array. If array is notmut
- a new clone of the array must be created, which will eat all optimizations we did in the searching algorithm (I suppose).In the production build (Clang), the new algorithm is faster on about 17% which can be handy.
If you want to review/retest my code, here it is -> https://pastebin.com/mvRLWNYs
Acknowledgements
Version used
V 0.3.4 e2f18fc.bc88183
Environment details (OS name and version, etc.)
Beta Was this translation helpful? Give feedback.
All reactions