Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zackriggle

Lists of lists :)

This topic is 5984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let's say I want to make a qeue (spelling?) for my main game process. The qeue would be a STL list containing a class (INTLIST -- See below). INTLIST would contain a STL list of ints. The qeue and INTLIST would each have their own iterator for the correct type. How would I be able to access the data pointed to by the iterator in INTLIST. class INTLIST { public: list thelist; list::iterator Ilist; }; class QEUE { public: list theqeue; list::iterator Iqeue; // IQ lol int GetSingleCommand(int qeue_pos, int list_pos); }; int QEUE::GetSingleCommand(int qp, int lp) { Iqeue = theqeue.begin(); (*Iqeue).Ilist = (*Iqeue).thelist.begin(); // <-- Don't know if this works (problem 1); for(int i = 0; i != qp; i++) Iqeue++; for(int x = 0; x != lp; x++) (*Iqeue).Ilist++; // Once again, the same problem return (*Iqeue).(*Ilist); // Problem 2... /* This returns a few compiler errors, which I will not post cuz Im lazy. I think you get what I mean but I do not know what to dereference and what not to (in the return statement). If I could make a list> qeue, but I think that would add complexity to it all (if it worked). AND THATS ABOUT IT BTW, HOW THE HELL DO I MAKE CODE BOXES?? Why don't we just kill the guys who write error messages. It'd make our lives a hell of a lot easier **************************** Gimme a break, I'm Just 13 (14 in JULY) [edited by - zackriggle on June 4, 2002 8:32:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
Code boxes are made with the [‍source] tag.

Since you are using the STL, you might as well use std::queue

      
#include <queue>

#include <list>


typedef std::queue<int, std::list<int> > Queue;


or just use a typedef for the list.

And you can make a list of lists by writing std::list<std::list<int> > with a space between the '> >'.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on June 4, 2002 8:37:18 PM]

[edited by - Fruny on June 4, 2002 8:39:29 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!