Accessing Map elements randomly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Suresh369
    New Member
    • Sep 2006
    • 10

    Accessing Map elements randomly

    HI,
    I have a need to randomly access a Map element.
    For this I tried:

    int entry ; //Randomly generated
    map<int, int> blah;
    map<int, int>::iterator blahI;

    blahI = element + blah.begin();

    But the compiler complains. I need to get an iterator to a particular element.
    Thanks
  • D_C
    Contributor
    • Jun 2006
    • 293

    #2
    Iterators should support relative addressing. Why don't you change your code to
    Code:
    data = *(entry+blah.begin());
    and see if it likes it.

    Comment

    Working...