Boost logo

Boost Users :

From: Andrew Holden (aholden_at_[hidden])
Date: 2006-11-08 11:56:23


Sebastian Redl wrote:

> james.jones_at_[hidden] wrote:
> > doing an array lookup is O(n).
> Huh?
> Array indexing is constant time. The compiler doesn't scan the array,
it
> uses the switch value directly as the index (after some mathematical
> transformation, perhaps.)

I think I see where the confusion came from: poor wording on my part.
In step three, where I talk about "looking stuff up" in the arrays, I
meant to say the array is indexed by the stuff, not that the runtime
must search for it. The lookup, in this case, is a simple indexing
operation, and is often implemented in one or two machine instructions.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net