Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5227

Re: random map

From Philipp Kraus <philipp.kraus@flashpixx.de>
Newsgroups comp.lang.c++
Subject Re: random map
Date 2011-05-21 08:11 +0200
Organization 1&1 Internet AG
Message-ID <ir7l2g$oma$1@online.de> (permalink)
References <ir6a6f$ekl$1@online.de> <4dd6d000$0$2880$7b1e8fa0@news.nbl.fi>

Show all headers | View raw


On 2011-05-20 22:33:04 +0200, Juha Nieminen said:

> Philipp Kraus <philipp.kraus@flashpixx.de> wrote:
>> But this does not work, I'll get an error on stl_bvector.h with
>> std::_Bit_iterator std::operator+. How can I get k random key values
>> out of my map?
> 
>   Do you understand the concept of random access iterators and why
> std::map iterators aren't?

std::advance shoudl be do something like this
for(i=0; i < n; ++i)
     iterator++;

In this case I can read / write any element in my map (bidirectional). 
I need a random access iterator, because I will nagivation to each 
element within the map in the worst-case in any order. But why can't I 
use iterator+n, because the map is sorted by the keys, so there is an 
order of the elements with transitivity dependency. ++ increses the 
iterator position element by element, but +n jump to the element 
directly.

Thx

Phil

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

random map Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-20 19:59 +0200
  Re: random map Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-20 20:12 +0200
    Re: random map Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-20 20:18 +0200
  Re: random map Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-20 20:36 +0200
  Re: random map Juha Nieminen <nospam@thanks.invalid> - 2011-05-20 20:33 +0000
    Re: random map Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-21 08:11 +0200
      Re: random map Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 08:32 +0000
        Re: random map Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-21 13:20 +0200

csiph-web