iterator for two lists

S

swtsvn

hi all
iam having two lists
list<float*> scan[10];

list<float*> AET;
and if i call list<float*>::iterator i;
the scan array of list pointers is getting referenced by the iterator

how do i access the iterator for AET which is just a general list

thanks
 
R

Rolf Magnus

swtsvn said:
hi all
iam having two lists
list<float*> scan[10];

Actually, you already have 10 lists here.
list<float*> AET;

And here is another one, so it's a total of 11.
and if i call list<float*>::iterator i;

You can't "call" an iterator. What do you mean by that?
the scan array of list pointers is getting referenced by the iterator

There is no array of list pointers. There is an array of lists, each
containig float pointers.
how do i access the iterator for AET which is just a general list

Just the same as you would for an element of your array. It's the same type,
and the iterator type for it is also list<float*>::iterator.

I'm not sure if that answered your question. Could you give an example of
how you try to use your iterators and lists and what problems you're
running into?
 
Ä

书呆彭

swtsvn 写é“:
hi all
iam having two lists
list<float*> scan[10];

list<float*> AET;
and if i call list<float*>::iterator i;
the scan array of list pointers is getting referenced by the iterator

how do i access the iterator for AET which is just a general list

thanks

I don't quite understand what your design does.

Why a list of pointers?

Usully the STL containers are used on objects or something.

Do you mean you need this:?

typedef std::list<std::auto_ptr<float> > list_t;

list_t AET;

list_t::iterator iter= AET.begin();

now you can use iter as an iterator.

But it is not good to store auto_ptr in list.
So you need to make your intention more clear.

Hope may help.
 
S

swtsvn

hi all
i found the solution
though both has list<float*>::iterator type, when i use it in the for
loop, i take the begin and end of the respective lists
for eg

my working code
list<float*>::iterator i,j;

for(k=0;k<10;k++){

for(i=scan[k].begin();i<scan[k].end();i++){
//do my work here
}
}

for(j=AET.begin();j<AET.end();j++){
//do my work here
}
i do not have my full code with me now,
so plz forgive me for any syntax error.
the reason y i need an array of (pointers to lists) is that
iam implementing scan line polygon fill algorithm for my class
assignment,
and the scan array is the edge table datastructure
and the AET list is the active edge table datastructure
hope i ve made my intentions clear

[...]
Do you mean you need this:?
typedef std::list<std::auto_ptr<float> > list_t;

That's not legal. You're not allowed to instantiate a list with
auto_ptr.
But it is not good to store auto_ptr in list.

It's not allowed by the standard. It's undefined behavior.

--
James Kanze (GABI Software) email:[email protected]
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top