Re: Best way to sort rooms...



This may be an unpopular sentiment for this list, but C++ makes this
trivial, typesafe, and free of memory leaks.  Assuming you have a "Room"
structure, you could define a "Building" as follows:

	#include <map>
	#include <string>
	using namespace std;

	typedef map<string, Room> Building;
	Building shipman_hall;

inserting a room into the building is as simple as:

	shipman_hall["113a"] = Room();

... and it will already be sorted.

Timothy M. Shead


"Shippy!" wrote:
> 
> I'm making a room scheduler program and what I would
> like to do is be able to dynamically add and delete
> different pages for each building, and then within
> each building tab, there will be another notebook
> with pages for each room in the building. I can do this
> just fine, but I would also like to sort the pages
> alphabetically, so when a new room or building
> is added, it's put in the right spot.
> 
> To throw another wrench into the plans, for each building
> and room I'm going to need to memorize the status of the widgets
> for each so I can save all of the data
> 
> I was thinking I could use a GList to link together
> a series of structures where each one would correspond
> to a building. Inside a building structure would be
> another GList with a series of structure for each room
> in that respective building with all of the
> widgets and data that I need contained within the
> structure. This make sense? I hope so.
> 
> Anyway, I don't know if this is the best way of doing
> this. If anybody has any design suggestions for something
> like this, I would really appreciate hearing them. Thanks!
> 
> +-----------------------------------------------------+
> | Jeff "Shippy" Shipman     E-Mail: shippy@cs.nmt.edu |
> | Computer Science Major    ICQ: 1786493              |
> | New Mexico Institute of Mining and Technology       |
> | Homepage: http://www.nmt.edu/~shippy                |
> +-----------------------------------------------------+




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]