473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

iterator for two lists

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
Sep 11 '08 #1
4 1976
swtsvn wrote:
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?

Sep 11 '08 #2
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.

Sep 11 '08 #3
On Sep 11, 7:18 am, ??? <lostgold...@163.comwrote:

[...]
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:ja*********@gmail.com
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34
Sep 11 '08 #4
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

On Sep 11, 3:33 am, James Kanze <james.ka...@gmail.comwrote:
On Sep 11, 7:18 am, ??? <lostgold...@163.comwrote:

[...]
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:james.ka...@gmail.com
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34
Sep 15 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Grant Edwards | last post by:
In an interview at http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273 Alan Kay said something I really liked, and I think it applies equally well to Python as well as the languages...
6
by: greg | last post by:
Hello all, I havent used STL containers much, as I am used to MFC containers/classes always ..The differences that I could see is iterators and algorithms. The algorithms providing some basic...
16
by: forester | last post by:
lets say its common situation when object have subobjects in container and receives callbacks from contained items. and object want to move objects in containers on signal(callback). iterator is...
13
by: Dan Tsafrir | last post by:
is the following code standard? (cleanly compiles under g++-4.0.2): struct Asc { bool operator()(int a, int b) {return a < b;} }; struct Des { bool operator()(int a, int b) {return b > a;} };...
7
by: andreas | last post by:
Hello, I have a problem with iterators in a fairly complex polygonal mesh data structure which is implemented using lists of geometric entities. However, the problem in itself is fairly simple:...
7
by: PengYu.UT | last post by:
I'm wondering is the standard defined behavior of past bound iterator. In the following example it seems that afer first "--it", it point to -1 index. I'm wondering if it is true independent of...
6
by: catphive.lists | last post by:
Is there a way to call erase(iter) on a list without invalidating the iterator? Can I make a copy of an iterator and then move forward the original without moving the copy? I'm aware of the...
1
by: alan.f22 | last post by:
HI First off, thanks for taking the time to read this. I have an class inheritance hierachy say: base class "E" and a bunch of derived classes (from "E") "A", "P", and "S" I have an STL...
2
by: Terry Reedy | last post by:
Luis Zarrabeitia wrote: Interesting observation. Iterators are intended for 'iterate through once and discard' usages. To zip a long sequence with several short sequences, either use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.