Click here to Skip to main content
15,909,498 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionmultithreading problem with boost Pin
Keith Vitali6-Feb-06 8:34
Keith Vitali6-Feb-06 8:34 
AnswerRe: multithreading problem with boost Pin
Stephen Hewitt6-Feb-06 12:39
Stephen Hewitt6-Feb-06 12:39 
GeneralRe: multithreading problem with boost Pin
Keith Vitali6-Feb-06 19:25
Keith Vitali6-Feb-06 19:25 
GeneralRe: multithreading problem with boost Pin
Stephen Hewitt6-Feb-06 19:29
Stephen Hewitt6-Feb-06 19:29 
QuestionVector question Pin
RobJones6-Feb-06 7:40
RobJones6-Feb-06 7:40 
AnswerRe: Vector question Pin
Maximilien6-Feb-06 7:52
Maximilien6-Feb-06 7:52 
AnswerRe: Vector question Pin
BlackDice6-Feb-06 9:00
BlackDice6-Feb-06 9:00 
AnswerRe: Vector question Pin
Stephen Hewitt6-Feb-06 11:48
Stephen Hewitt6-Feb-06 11:48 
First you need a way of comparing s_items for equality based on the strDevice string:
struct DeviceIDsEqual : binary_function<s_item, s_item, bool>
{
     bool operator()(const s_item& f, const s_item& s) const
     {
         return f.strDevice == s.strDevice;
     }
}


We also need the vector sorted so we need to compare if one s_item is less the another based on the strDevice string.
struct DeviceIDsLess : binary_function<s_item, s_item, bool>
{
     bool operator()(const s_item& f, const s_item& s) const
     {
         return f.strDevice < s.strDevice;
     }
}


Now we first sort then eliminate duplicates:
typedef vector<s_item>::iterator VI;
sort(v_items.begin(), v_items.end(), DeviceIDsLess());
VI newEnd = unique(v_items.begin(), v_items.end(), DeviceIDsEqual());
m_items.erase(newEnd, v_items.end());


Of if you just want to find the duplicates you can use the adjacent_find algorithm.

This code needs the following includes:
 <functional>
 <algorithm>
and the following:
 using namespace std;


Steve


-- modified at 23:48 Monday 6th February, 2006
GeneralRe: Vector question Pin
RobJones7-Feb-06 1:09
RobJones7-Feb-06 1:09 
QuestionUNICODE display Pin
transoft6-Feb-06 7:32
transoft6-Feb-06 7:32 
QuestionGauge controls for MFC Pin
Andre xxxxxxx6-Feb-06 7:18
Andre xxxxxxx6-Feb-06 7:18 
QuestionDownloading a File using Win32/C Pin
Mike Doner6-Feb-06 4:48
Mike Doner6-Feb-06 4:48 
AnswerRe: Downloading a File using Win32/C Pin
James R. Twine6-Feb-06 4:57
James R. Twine6-Feb-06 4:57 
AnswerRe: Downloading a File using Win32/C Pin
rrrado6-Feb-06 4:57
rrrado6-Feb-06 4:57 
QuestionModeless dialog clipped by it's parent dialog Pin
rrrado6-Feb-06 4:11
rrrado6-Feb-06 4:11 
AnswerRe: Modeless dialog clipped by it's parent dialog Pin
James R. Twine6-Feb-06 4:39
James R. Twine6-Feb-06 4:39 
GeneralRe: Modeless dialog clipped by it's parent dialog Pin
rrrado6-Feb-06 4:53
rrrado6-Feb-06 4:53 
AnswerRe: Modeless dialog clipped by it's parent dialog Pin
Maximilien6-Feb-06 7:05
Maximilien6-Feb-06 7:05 
QuestionSelect Row in ListView Pin
RadioOpa6-Feb-06 4:05
RadioOpa6-Feb-06 4:05 
AnswerRe: Select Row in ListView Pin
rrrado6-Feb-06 4:14
rrrado6-Feb-06 4:14 
AnswerRe: Select Row in ListView Pin
RChin6-Feb-06 4:14
RChin6-Feb-06 4:14 
GeneralRe: Select Row in ListView Pin
RadioOpa6-Feb-06 4:34
RadioOpa6-Feb-06 4:34 
AnswerRe: Select Row in ListView Pin
James R. Twine6-Feb-06 4:42
James R. Twine6-Feb-06 4:42 
AnswerRe: Select Row in ListView Pin
RadioOpa6-Feb-06 4:45
RadioOpa6-Feb-06 4:45 
QuestionTimer Pin
LCI6-Feb-06 3:36
LCI6-Feb-06 3:36 

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.