Bug 12762 – Missing documentation for std.range.SearchPolicy.linear
Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-18T08:04:00Z
Last change time
2014-07-16T04:17:27Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-05-18T08:04:53Z
In this page:
http://dlang.org/phobos/std_range.html#SearchPolicy
The documentation about the enum std.range.SearchPolicy states:
enum SearchPolicy: int;
Policy used with the searching primitives lowerBound, upperBound, and equalRange of SortedRange below.
trot
Searches with a step that is grows linearly (1, 2, 3,...) leading to a quadratic search schedule (indexes tried are 0, 1, 3, 6, 10, 15, 21, 28,...) Once the search overshoots its target, the remaining interval is searched using binary search. The search is completed in ?(sqrt(n)) time. Use it when you are reasonably confident that the value is around the beginning of the range.
gallop
Performs a galloping search algorithm, i.e. searches with a step that doubles every time, (1, 2, 4, 8, ...) leading to an exponential search schedule (indexes tried are 0, 1, 3, 7, 15, 31, 63,...) Once the search overshoots its target, the remaining interval is searched using binary search. A value is found in ?(log(n)) time.
But in the source code the enum contains a "linear" too:
/**
Policy used with the searching primitives $(D lowerBound), $(D
upperBound), and $(D equalRange) of $(LREF SortedRange) below.
*/
enum SearchPolicy
{
/**
Searches in a linear fashion.
*/
linear,
/**
Searches with a step that is grows linearly (1, 2, 3,...)
leading to a quadratic search schedule (indexes tried are 0, 1,
3, 6, 10, 15, 21, 28,...) Once the search overshoots its target,
the remaining interval is searched using binary search. The
search is completed in $(BIGOH sqrt(n)) time. Use it when you
are reasonably confident that the value is around the beginning
of the range.
*/
trot,
Comment #1 by hsteoh — 2014-07-16T04:10:17Z
Actually, this is because dlang.org hasn't been updated with the latest Phobos docs yet. I just built the Phobos docs from git HEAD locally, and 'linear' is properly documented as expected. Probably this disparity will be reconciled when 2.066 is released. :)
Comment #2 by hsteoh — 2014-07-16T04:17:27Z
P.S. Just for the record, here's how to build the docs:
1) git clone the dlang.org repo from github, say into /path/to/d/dlang.org (assuming phobos lives in /path/to/d/phobos)
2) cd /path/to/d/dlang.org ; make -f posix.mak html # this creates html and css files in /path/to/d/dlang.org/web
3) cp -rp web ../ # copy docs to /path/to/d/web, just because that's where the phobos makefile expects it to be
4) cd ../phobos ; make -f posix.mak html # this will generate the phobos docs into /path/to/d/web
5) copy /path/to/d/web to your web folder and point your browser there.