← Back to index
|
Original Bugzilla link
Bug 15385 – Apply Andersson91 idea to SortedRange.contains
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-28T20:02:00Z
Last change time
2016-01-11T20:50:39Z
Assigned to
nobody
Creator
andrei
Comments
Comment #0
by andrei — 2015-11-28T20:02:00Z
http://user.it.uu.se/~arnea/ps/searchproc.pdf
describes a simple trick that reduces the number of comparisons in a binary search. The same idea can be used for binary search in an array. The idea is to save an index (not a node as described in the paper). In
https://github.com/D-Programming-Language/phobos/blob/master/std/range/package.d#L7833
the routine could do only one evaluation of predFun and then continue searching. Only when the count goes down to zero is the other comparison done.
Comment #1
by github-bugzilla — 2015-11-30T01:34:39Z
Commits pushed to master at
https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/dda21ec7d1bee229c3e5af80fa06162735a74cb7
Issue 15385
https://github.com/D-Programming-Language/phobos/commit/4a12bd6e08489fba159d307f1ef9059e18fcd4f2
Merge pull request #3844 from Xinok/issue15385 Fix Issue 15385 - SortedRange.contains() optimize predicate calls
Comment #2
by github-bugzilla — 2016-01-03T14:15:06Z
Commits pushed to stable at
https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/dda21ec7d1bee229c3e5af80fa06162735a74cb7
Issue 15385
https://github.com/D-Programming-Language/phobos/commit/4a12bd6e08489fba159d307f1ef9059e18fcd4f2
Merge pull request #3844 from Xinok/issue15385