Switch implementation

bearophile bearophileHUGS at lycos.com
Tue Sep 28 17:45:27 PDT 2010


retard:

> Instead of O(n) linear search or O(ln n) binary search, why not use O(1) 
> jump tables in this case?

I don't exactly know. But you must take into account the constants too, it's not just a matter of worst-case computational complexity. Probably when the density of a large jump table becomes too much low, its experimental performance on modern CPUs gets worse than a binary search among few entries. But I am not sure, I have not written&run benchmarks on this.

Bye,
bearophile


More information about the Digitalmars-d mailing list