|
Boost : |
From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2006-10-31 05:20:05
> On 10/30/06, Jason Hise <0xchaos_at_[hidden]> wrote:
>> Actually, I wonder if it is even valid to say
>> that this container supports random access... although it supports
>> the syntax for it, isn't random access defined as being constant
>> time?
>
From: Michael Fawcett
> I don't think so. I'm pretty sure RandomAccess only means that the
> iterator supports the required arithmetic syntax, i.e. ++iter, iter++,
> iter + n, iter += n. I am by no means an iterator guru.
Sorry. Jason is right. Section 24.1 paragraph 8 of the standard:
All the categories of iterators require only those functions that
are realizable for a given category in constant time (amortized).
(If there weren't a constant time requirement, there would be no point
in distinguishing bi-directional iterators from random access iterators.
bi-directional iterators can always implement += n by repeated
increment.)
-- Martin Bonner Martin.Bonner_at_[hidden] Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB24 6WZ, ENGLAND Tel: +44 (0)1223 203894
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk