Computing.Net > Forums > Programming > C++ List of Lists

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ List of Lists

Reply to Message Icon

Name: L33TRice
Date: October 21, 2007 at 01:42:49 Pacific
OS: Sun Unix
CPU/Ram: Unknown
Product: Sun
Comment:

I'm writing a program that stores music information. I have a class called Song that holds song information (song ID, song name, length etc.) and class called Playlist that holds an integer essentially (that references the song ID) and I have a linked list class. (I'm writing my own lists because this is a data structures class). My problem is that I need to be able to dynamically create playlists because the user is supposed to be able to make as many as they want. My professor suggested using a list of lists, but he is being very vague with the syntax. Basically I want a List(of strings i.e. the name of the playlist) that contains lists of the Playlist class. my general understanding of constructing this is (assuming my list class is called "List":
List<List<Playlist> > playList;

Now theoretically if I have an insert operator in the List class, I can insert a string for a playlist (i.e. "Classical_Songs"), but I'm not sure how to do it. (playList.insert(somename);?) Futhermore, if I actually want to edit the contents of the list "Class Songs" and add song id numbers, I have no idea where to start. Would I just be able to use "Classical _Songs.insert(somevalue); ?

Any help would be GREATLY appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 22, 2007 at 01:01:31 Pacific
Reply:

It would depend on the contents of your List<T> class, but I suspect you more-or-less have it.

List<List<Playlist> > playList;
That would create a List of Lists (of Playlists).

playList.insert(somename);
Again, it would depend on your insert, but I assume that would have to insert a List<Playlist>, not a Song.

Classical _Songs.insert(somevalue);
You would have to reference your Classical_Songs from the master list class.

The easiest way to go about it would probably be to make it work for a single List<Playlist>, then go back and add the master List<List<Playlist> > playList;.

I'd love to be of more help, but I don't get your description, and you didn't post any source code.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ List of Lists

is really c++ incrementation of c? www.computing.net/answers/programming/is-really-c-incrementation-of-c/7053.html

C++ lists in dos. www.computing.net/answers/programming/c-lists-in-dos/1453.html

C++ problem of arrays and functions www.computing.net/answers/programming/c-problem-of-arrays-and-functions/7296.html