Click here to Skip to main content
15,892,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: operator ":" new for me in C++ PinPopular
Iain Clarke, Warrior Programmer16-Jan-11 1:36
Iain Clarke, Warrior Programmer16-Jan-11 1:36 
AnswerRe: operator ":" new for me in C++ PinPopular
Aescleal16-Jan-11 9:01
Aescleal16-Jan-11 9:01 
AnswerRe: operator ":" new for me in C++ Pin
moemass17-Jan-11 3:12
moemass17-Jan-11 3:12 
QuestionHow to get computer color setting? Pin
includeh1015-Jan-11 20:37
includeh1015-Jan-11 20:37 
AnswerRe: How to get computer color setting? Pin
Andrew Brock15-Jan-11 20:53
Andrew Brock15-Jan-11 20:53 
GeneralRe: How to get computer color setting? Pin
includeh1016-Jan-11 2:47
includeh1016-Jan-11 2:47 
GeneralRe: How to get computer color setting? Pin
Andrew Brock16-Jan-11 2:51
Andrew Brock16-Jan-11 2:51 
QuestionSorting data using std::map or std::multimap Pin
cmacgowan15-Jan-11 14:19
cmacgowan15-Jan-11 14:19 
Hi ...

Happy New Year. Hope everyone is ok. I have not been here for a while.

I have some contact lens data I'm trying to sort. I have some sort rules are static (hard-coded) followed by other rules form 'normal' rules

Here are the requirements:

1. First sort by Company and Product is a static order (hard-coded, non alphbetic)

Sample
o Company ProductName
--------------------------------------------------------------------
1. Ciba 1. Focus, 2. AirOptics, 3. Dailies, 4. then alphabetical.
2. Bausch & Lomb 1. PureVision, 2. LiquidEye, 3. Softlens then alphabetical.

2. Followed by Package size decending (80, 30 ...)

3. Followed by Base Curve decending (8.6, 8,0 ...)

4. Followed by Sphere decending (-0.5, 0.0, 1.0 ...)

In the end the result might look like the following

Sample data
CO PR PS BC Sp
-------------------------------
Ciba Focus 10 8.6 0.00
Ciba Focus 20 8.6 -0.25
Ciba Focus 20 8.6 -0.10
Ciba Focus 20 8.6 +0.25
Ciba Air 10 8.6 -0.25
Ciba Air 10 8.6 -0.10
Ciba Air 20 8.1 -0.25
Ciba Air 20 8.1 -0.10
Ciba Air 20 8.1 0.00
Ciba Air 20 8.6 +0.25
Ciba Air 20 8.6 +0.40


The data is contained in a struct with other data. The stuct is used in a map with a key. I am building a key to sort for the static requirments such as below.

The key contains a prefix at the front of the key to force the static sort (non alphabetical), followed by a suffix to make the key unique. Sample key: "1_1_Ciba_Focus Monthlys_4"

My plan to sort the other requirments is to take each of the other requirments (PackageSize, Base Curve and Sphere) and sort them against the previous element with the key.

Since I will be sorting the following agaist the Package Size (10, 20 ...) - maybe I should be using the multimap, as it might be easter to sort this stuff without having the unique ID at the end of key ??

With the key of "1_1_Ciba Focus" I would sort on the PackSize and then set the key to produce the correct sort

start: (std::multimap)
key: 1_1_Ciba Focus"
Sample data
CO PR Key
-------------------------------
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus

Sample data
CO PR PS Key
-------------------------------
Ciba Focus 10 1_1_1_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus


Thanks,
Chris
chris@macgowan.com
AnswerRe: Sorting data using std::map or std::multimap Pin
Andrew Brock15-Jan-11 18:08
Andrew Brock15-Jan-11 18:08 
GeneralRe: Sorting data using std::map or std::multimap Pin
cmacgowan16-Jan-11 11:01
cmacgowan16-Jan-11 11:01 
AnswerRe: Sorting data using std::map or std::multimap Pin
Aescleal16-Jan-11 6:10
Aescleal16-Jan-11 6:10 
GeneralRe: Sorting data using std::map or std::multimap Pin
cmacgowan16-Jan-11 11:02
cmacgowan16-Jan-11 11:02 
QuestionSoftware Keyboard Simulator Pin
RedDragon2k15-Jan-11 4:48
RedDragon2k15-Jan-11 4:48 
AnswerRe: Software Keyboard Simulator Pin
jschell15-Jan-11 10:02
jschell15-Jan-11 10:02 
AnswerRe: Software Keyboard Simulator Pin
Andrew Brock15-Jan-11 17:16
Andrew Brock15-Jan-11 17:16 
AnswerRe: Software Keyboard Simulator Pin
loyal ginger15-Jan-11 17:25
loyal ginger15-Jan-11 17:25 
GeneralRe: Software Keyboard Simulator Pin
RedDragon2k16-Jan-11 4:11
RedDragon2k16-Jan-11 4:11 
QuestionHow to Set Position where a Window will be minimised Pin
SoftwareDeveloperGoa15-Jan-11 4:42
SoftwareDeveloperGoa15-Jan-11 4:42 
AnswerRe: How to Set Position where a Window will be minimised Pin
Emilio Garavaglia15-Jan-11 7:09
Emilio Garavaglia15-Jan-11 7:09 
GeneralRe: How to Set Position where a Window will be minimised Pin
SoftwareDeveloperGoa15-Jan-11 7:17
SoftwareDeveloperGoa15-Jan-11 7:17 
GeneralRe: How to Set Position where a Window will be minimised Pin
Emilio Garavaglia15-Jan-11 8:52
Emilio Garavaglia15-Jan-11 8:52 
GeneralRe: How to Set Position where a Window will be minimised Pin
SoftwareDeveloperGoa15-Jan-11 9:01
SoftwareDeveloperGoa15-Jan-11 9:01 
QuestionWhat wrong with this loop? Pin
Le@rner14-Jan-11 19:34
Le@rner14-Jan-11 19:34 
AnswerRe: What wrong with this loop? Pin
Andrew Brock14-Jan-11 21:10
Andrew Brock14-Jan-11 21:10 
AnswerRe: What wrong with this loop? Pin
jixuduxing14-Jan-11 22:37
jixuduxing14-Jan-11 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.