Window sizing/theory help

Started by
3 comments, last by dave 17 years, 1 month ago
OK, I could use a little help in two areas here: I'll first explain my application: Its a media player using the windows MCI (I may create my own MP3 decoding DLLs down the line) which has a playlist, prev, next, add folder, add file and so on. The very quick way to make the player work that I took, while being very memory inefficient, was fast - I used an array of structs. I recently switched it over to using a linked list (I'm in C#) - I defined a struct called node:

public struct node
        {
            public int tracknum;
            public string filepath;
            public string filename;
            public string artist;
            public string album;
            public string song;
            public string duration;
        }
and used the generics linked list class, using that node as my template. My question is this - is there a better way to store each song's info other than this? One of my main reasons I ask is that if someone double clicks a song to play, I need to get a int of which index they clicked, and then find that in my linked list (hence why tracknum is in there) but that means going through the whole bloody list! Worse will be if I add something like "Move up" and "move down", as I will have to change values and all... Other question: I used a listview to display my playlist - how can I make it so that if I allow he user to resize the window, the listview will be resized with it? Thanks! Screenshot if it helps: http://i19.photobucket.com/albums/b164/jaguar4192/csmedia.jpg
Advertisement
If this were C++ i'd shuffle the songs by name, store them in a map and then have them all indexed in a vector. That way lookup is very fast for large numbers of songs with the map and i can sort the contents by using a vector of pointers and using std::sort.

Mayeb you can try and work C# to do something similar.

Dave
Quote:Original post by Dave
If this were C++ i'd shuffle the songs by name, store them in a map and then have them all indexed in a vector. That way lookup is very fast for large numbers of songs with the map and i can sort the contents by using a vector of pointers and using std::sort.

Mayeb you can try and work C# to do something similar.

Dave


I'm unfamiliar with maps? I never encountered them in C++...I'll look around for an example and see if I can get that.

I was trying to avoid using pointers though, as the compiler complains when you put them in (you need to mark pointers as unsafe, and set the compiler to include unsafe code...)
Quote:Original post by Anonymous Poster
Quote:Original post by Dave
If this were C++ i'd shuffle the songs by name, store them in a map and then have them all indexed in a vector. That way lookup is very fast for large numbers of songs with the map and i can sort the contents by using a vector of pointers and using std::sort.

Mayeb you can try and work C# to do something similar.

Dave


I'm unfamiliar with maps? I never encountered them in C++...I'll look around for an example and see if I can get that.

I was trying to avoid using pointers though, as the compiler complains when you put them in (you need to mark pointers as unsafe, and set the compiler to include unsafe code...)


Also, are maps dynamic with memory usage? I want something not constrained to a certain amount of memory usage.
Well in C++ the map stores a pointer, how you give the pointer a value is up to you, be it 'new' or not. The map is only responsible for the pointers, not what the pointers point to.

This topic is closed to new replies.

Advertisement