Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-04-07 20:23:19


Gennadiy Rozental wrote:
> Could you clarify in which case loop-unrolling would provide O(1)
> complexity?

Assuming your assertion that a switch-based visitation algorithm is indeed
O(1), then the following loop-unrolling approach would provide O(1) for the
first N types:

  switch (which_) {
    case 1: visitor( reinterpret_cast<T1>( ... ) ); break;
    ...
    case N: visitor( reinterpret_cast<TN>( ... ) ); break;
    default:
        <some code to handle next N types>
  }

Let me know if this resolves the issue.

Thanks,
Eric


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk