Open caterchong opened 2 years ago
when calling DescendRange methods, an iteration is performed.
All items between [lessOrEqual, greaterThan ) are iterated.
Suppose there're n items in the range, I though Less function is called log(n) times.
However, Less is called more than n times as a matter of
if stop != nil && !n.items[i].Less(stop) { return hit, false }
Why make comparisons this way? I though if parent node can decide all its children are in the range, most Less(stop) call can be optimized out.
Are there anything wrong with this idea?
@caterchong I have submitted a PR base on your idea.
when calling DescendRange methods, an iteration is performed.
All items between [lessOrEqual, greaterThan ) are iterated.
Suppose there're n items in the range, I though Less function is called log(n) times.
However, Less is called more than n times as a matter of
Why make comparisons this way? I though if parent node can decide all its children are in the range, most Less(stop) call can be optimized out.
Are there anything wrong with this idea?