Accessing Portion(s) of STL Container

M

Mike Copeland

Is there a way to access a "chunk" (or portion) of an STL map? That
is, I have a map declared, and it will normally contain more than, say,
25 objects. I want to display 25 objects at a time, e.g. 1-25, 26-50,
etc. Of course, I don't expect to have multiples of 25 to work with, so
I want to know when the what's in the last "page" of display data.
Please advise. TIA
 
I

Ian Collins

Is there a way to access a "chunk" (or portion) of an STL map? That
is, I have a map declared, and it will normally contain more than, say,
25 objects. I want to display 25 objects at a time, e.g. 1-25, 26-50,
etc. Of course, I don't expect to have multiples of 25 to work with, so
I want to know when the what's in the last "page" of display data.

Unlike say a vector, the order of element in a map is dynamic and the
storage isn't contiguous, so you can't really do what you are asking.
 
M

Mike Copeland

Is there a way to access a "chunk" (or portion) of an STL map? That
As long as you are not adding to, or removing from the map, you could
simply iterate through it 25 elements at a time.
That's the case with my data, but _how_ do I access, say, objects 26-
50 without "picking" that range as I iterate through the entire data
set?
 
I

Ian Collins

That's the case with my data, but _how_ do I access, say, objects 26-
50 without "picking" that range as I iterate through the entire data
set?

As I said in my other reply, you can't.
 
R

RaZiel

That's the case with my data, but _how_ do I access, say, objects 26-
50 without "picking" that range as I iterate through the entire data
set?

You could use a second map, mapping position to key value in the first map.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top