473,769 Members | 7,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a list of multiple element rows, and sorting them.

Daz
Hi everyone.

I am trying to make a program which handles about 70 different objects,
of the same type. The properties are as follows:

std::string ItemName
int ItemType
int Calories
int Weight
int Density

I am looking for a way of sorting the list during the several stages of
their handling.proces sing, but I don't have a clue where to start. The
list will need to be sorted 3 times, once by Calories, once by Weight,
and then again by Density.

Obviously, I can put each property into a vector, and then sort them,
but this doesn't sort the others into their respective positions (they
need to be handled as rows of data). I am sure that I am either not
realizing the full potential of a vector, or I need to use/create
something else, such as a custom class based on a vector, but I am
really not sure.

I would appreciate any suggestions.

Thanks in advance.

Daz

Jul 2 '06 #1
2 1745
Daz wrote:
Hi everyone.

I am trying to make a program which handles about 70 different objects,
of the same type. The properties are as follows:

std::string ItemName
int ItemType
int Calories
int Weight
int Density

I am looking for a way of sorting the list during the several stages of
their handling.proces sing, but I don't have a clue where to start. The
list will need to be sorted 3 times, once by Calories, once by Weight,
and then again by Density.
For a small data set like this, you might as well use 3 maps
(std::map<int,O bject*>), and you your three sort criteria as the keys.

--
Ian Collins.
Jul 2 '06 #2
Daz

Ian Collins wrote:
For a small data set like this, you might as well use 3 maps
(std::map<int,O bject*>), and you your three sort criteria as the keys.

--
Ian Collins
Thanks Ian! I will look into that. :)

Jul 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10899
by: bissatch | last post by:
Hi, I am about to write an application that will display all pdf files in a folder and display them by file name in order of date. Is there an easy way of doing this? I was thinking about somehow adding filename and date created in an array, sorting by date and then printing onto an html page with a link to that file. How would I do this though? Is this the simplest method or is there a better way of doin this?
1
5291
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so the user doesn't have to scroll horizontally. Essentially, I want to wrap a datagrid row (not text in individual columns) with as much control as possible. Make sense? While this seems simple enough on the surface, I can't figure out how to do...
0
2013
by: Patrick.O.Ige | last post by:
I have a datagrid with checkboxes.. When a user clicks one check box and clicks the delete button it deletes that ROw. There another situation when a user clicks multiple rows so i had to loop throug the rows like so:- foreach (DataGridItem i in DataGrid1.Items) { CheckBox deleteChkBxItem = (CheckBox) i.FindControl ("DeleteRow"); if (deleteChkBxItem.Checked) {
6
7257
by: Adam Tilghman | last post by:
Hi all, I have found that IE doesn't seem to respect the <SELECT> "multiple" attribute when set using DOM methods, although the attribute/property seems to exist and is updated properly. Those changes just don't make it onto the screen. Am I doing something wrong here? If not, is there a better feature test I can use than "appName.match()"?
10
5101
by: moondaddy | last post by:
I'm new to c# and .net 2.0. In the old vb.net 1.1 days I normally created a list class for every business class and used this list class for all databinding rather than using datasets. This is because often I wanted to edit data in the list and therefore needed to talk to the business object and not the dataset. Since this was a must, I standardized on creating list objects in most cases so everything was standardized. I've searched far...
1
2099
by: Alan_C | last post by:
Hi, Using Perl I converted a few simple, single header, csv to xml. But I have a csv file that has: Header,row,#1 data_row,under,header_1 nuther_data_row,under,header_1 Header,row,number,two data_row,under,header,2
0
1339
by: =?Utf-8?B?U3RldmU=?= | last post by:
C# I have a datagrid, and the users are able to select multiple rows and perform an action. This works fine, as I get the rows selected using something like this: CurrencyManager xCM = (CurrencyManager)dgWork.BindingContext; DataView xDV = (DataView)xCM.List;
6
12696
by: dufnobles via AccessMonster.com | last post by:
I have a form that excepts text input from a user. I would like to have the form display the same line several times so that the user can enter several different responses on one form screen. How can I display the same line of identical textfields five different times on the same form (each with a different line number)? Once this happens, how do I insert all of them into the same table? Thanks -- Message posted via...
2
5900
newnewbie
by: newnewbie | last post by:
I am learning VBA and need a little help with a macro that I am writing. I have a worksheet with data that I split into multiple worksheets based on criteria in one column. E.g. Column A has unique usernames, I have a macro (found it online and tweaked) that splits the spreadsheet (Sheet1) into different tabs named by the criteria (lgold, gsmth, ppatty, etc.). So, as a starting point I have an excel file with 20-30 tabs. all named differently,...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.