Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Multithreading Pin
Naveen1-Mar-06 23:28
Naveen1-Mar-06 23:28 
AnswerRe: Multithreading Pin
Cedric Moonen1-Mar-06 21:00
Cedric Moonen1-Mar-06 21:00 
GeneralRe: Multithreading Pin
Waldermort1-Mar-06 21:54
Waldermort1-Mar-06 21:54 
GeneralRe: Multithreading Pin
Cedric Moonen1-Mar-06 22:19
Cedric Moonen1-Mar-06 22:19 
AnswerRe: Multithreading Pin
Joe Woodbury1-Mar-06 21:20
professionalJoe Woodbury1-Mar-06 21:20 
Questionc++ Pin
yaaqub1-Mar-06 20:28
yaaqub1-Mar-06 20:28 
AnswerRe: c++ Pin
Nibu babu thomas1-Mar-06 20:33
Nibu babu thomas1-Mar-06 20:33 
AnswerRe: c++ Pin
Stephen Hewitt1-Mar-06 22:28
Stephen Hewitt1-Mar-06 22:28 
Here is an example of how to use std::sort:
-------------------------------------------

#include <iostream>
#include <algorithm>
#include <iterator>
using namespace std;

// Our data.
struct Blah
{
Blah(int Type, const char* pName) :
m_Type(Type), m_pName(pName)
{
}

int m_Type;
const char* m_pName;
};

// Print out a blah.
ostream& operator<<(ostream& s, const Blah& b)
{
s << "Type: " << b.m_Type << ", Name: \"" << b.m_pName << "\"";
return s;
}

// Sort functors.
struct SortByType
{
bool operator()(const Blah& l, const Blah& r) const
{
return l.m_Type < r.m_Type;
}
};

struct SortByName
{
bool operator()(const Blah& l, const Blah& r) const
{
return strcmp(l.m_pName, r.m_pName) < 0;
}
};

struct SortByTypeThenName
{
bool operator()(const Blah& l, const Blah& r) const
{
return SortByType()(l, r) | (!SortByType()(r, l) && SortByName()(l, r));
}
};

// The data.
Blah g_Blahs[] =
{
Blah(1, "George"), Blah(2, "Liam"), Blah(2, "Hank"),
Blah(0, "Abigail"), Blah(1, "Bob"), Blah(0, "Jessica"),
Blah(2, "Con"), Blah(1, "Kyle"), Blah(0, "Faye")
};

int main(int argc, char* argv[])
{
Blah* pBegin = &g_Blahs[0];
Blah* pEnd = &g_Blahs[sizeof(g_Blahs)/sizeof(g_Blahs[0])];
ostream_iterator<Blah> oi(cout, "\n");

// Sort by type.
cout << "Type:\n";
sort(pBegin, pEnd, SortByType());
copy(pBegin, pEnd, oi);
cout << "\n";

// Sort by name.
cout << "Name:\n";
sort(pBegin, pEnd, SortByName());
copy(pBegin, pEnd, oi);
cout << "\n";

// Sort by type and name.
cout << "Type and name:\n";
sort(pBegin, pEnd, SortByTypeThenName());
copy(pBegin, pEnd, oi);
cout << "\n";

return 0;
}


Steve
QuestionCombo box height is not increasing Pin
BiswaR1-Mar-06 19:45
BiswaR1-Mar-06 19:45 
AnswerRe: Combo box height is not increasing Pin
Naveen1-Mar-06 20:42
Naveen1-Mar-06 20:42 
QuestionUsing Serial Port communication for dialog based application Pin
BeakX1-Mar-06 19:44
BeakX1-Mar-06 19:44 
AnswerRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 20:26
Cedric Moonen1-Mar-06 20:26 
GeneralRe: Using Serial Port communication for dialog based application Pin
Rick York1-Mar-06 21:50
mveRick York1-Mar-06 21:50 
GeneralRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 22:00
Cedric Moonen1-Mar-06 22:00 
Questionhow to show images on window and move. Pin
baldha rakesh1-Mar-06 19:19
baldha rakesh1-Mar-06 19:19 
AnswerRe: how to show images on window and move. Pin
Nibu babu thomas1-Mar-06 19:54
Nibu babu thomas1-Mar-06 19:54 
GeneralRe: how to show images on window and move. Pin
baldha rakesh1-Mar-06 20:14
baldha rakesh1-Mar-06 20:14 
QuestionHow to test the MTTTY example of serial comm in Win32 console? Pin
pkyiu1-Mar-06 19:17
pkyiu1-Mar-06 19:17 
QuestionHow to convert exe to dll Pin
BicycleTheif1-Mar-06 18:38
BicycleTheif1-Mar-06 18:38 
AnswerRe: How to convert exe to dll Pin
Naveen1-Mar-06 18:49
Naveen1-Mar-06 18:49 
Questionrelated to images Pin
baldha rakesh1-Mar-06 17:19
baldha rakesh1-Mar-06 17:19 
AnswerRe: related to images Pin
Nibu babu thomas1-Mar-06 17:36
Nibu babu thomas1-Mar-06 17:36 
AnswerRe: related to images Pin
Naveen1-Mar-06 17:39
Naveen1-Mar-06 17:39 
AnswerRe: related to images Pin
Hamid_RT1-Mar-06 18:05
Hamid_RT1-Mar-06 18:05 
Questionimage processing Pin
elips1-Mar-06 17:12
elips1-Mar-06 17:12 

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.