i need some help on how to traversing my data structure. the purpose of this structure is to emulate a Data Grid View structure(at least as i understand it). overall, it should basically do what the windows media player library does.
that is to say:
-holds data across various categories
-sorts the music files based on these categories
explained in terms of a music library, the DS is implemented in terms of rows(representing songs) and columns(representing categories)(note: these are ACTUAL list objects - as opposed to 'rules' in terms of usage). all the rows are stored collectively in a STL list, likewise with the columns.
i want to make this DS function like a STL container. as such, it requires iterators. the problem originates with the fact that this DS is essentially a matrix, whereas all the STL containers can be visualized as 'lines'. i have to incorporate some EFFECTIVE way to navigate both columns and rows.
the method i'm currently using has iterators ONLY traversing the list of rows. once a row/reference has been retrieved, you can call the subscript operator on it and use it to call up the specific column you want.
however, i want to hear opinions on how to traverse a matrix-like, STL-emulating datastructure as my way feels extremely clunky(although not the worst of possible options).
traversing a matrix-like data structure?
Page 1 of 11 Replies - 2526 Views - Last Post: 29 July 2008 - 11:39 AM
Replies To: traversing a matrix-like data structure?
#2
Re: traversing a matrix-like data structure?
Posted 29 July 2008 - 11:39 AM
Sounds ok to me. You have a container for the rows, and each row presumably has another container to represent the columns.
Presumably you have something like:
What kind of query functions do you require? This would be what will effect efficiency of lookups and how much you want to store, i.e. in Row I have put a: int index , the purpose being you could provide a function/operator[] to find a row based on its index.
Presumably you have something like:
struct Song
{
// song stuff
string sName, sArtist;
}
struct Row
{
int index;
map<int, Column *> cols; // int is the column index
// destructor to delete each Column (or use smart pointer)
}
struct Column
{
string name;
Song * song;
// destructor to delete Song (or use smart pointer)
}
What kind of query functions do you require? This would be what will effect efficiency of lookups and how much you want to store, i.e. in Row I have put a: int index , the purpose being you could provide a function/operator[] to find a row based on its index.
This post has been edited by Teaser: 29 July 2008 - 11:41 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|