|
![](/i/fill.gif) |
Ron Parker <ron### [at] povray org> wrote:
: Perl doesn't have what you'd call "iterators" per se. To iterate over an
: associative array in Perl, you do:
: for $index ( keys( %assoc_array ) ) {
: do_stuff_with( $assoc_array{$index} )
: }
I think this is slower than using iterators.
Referencing to an object with an iterator is a constant-time operation
and incrementing the iterator is an amortized constant-time operation.
Thus, going through the whole array is an O(n)-time operation.
Indexing one element with a key is an O(log n)-time operation (at least
with the STL map), so going through all elements by indexing each one of
them would be a O(n*log n)-time operation.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
![](/i/fill.gif) |