Click here to Skip to main content
15,918,808 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionDo not Open Dialog on IE7 MultipleTab Pin
preeti sharma26-Aug-08 21:23
preeti sharma26-Aug-08 21:23 
AnswerRe: Do not Open Dialog on IE7 MultipleTab Pin
Michael Dunn29-Aug-08 13:41
sitebuilderMichael Dunn29-Aug-08 13:41 
QuestionCapturing IE events with using RBDESKBAND Pin
skumar120921-Aug-08 19:45
skumar120921-Aug-08 19:45 
Questionunique problem Pin
s196675m10-Aug-08 8:10
s196675m10-Aug-08 8:10 
AnswerRe: unique problem Pin
s196675m12-Aug-08 18:34
s196675m12-Aug-08 18:34 
AnswerRe: unique problem Pin
Stuart Dootson12-Aug-08 21:38
professionalStuart Dootson12-Aug-08 21:38 
GeneralRe: unique problem Pin
s196675m13-Aug-08 6:48
s196675m13-Aug-08 6:48 
GeneralRe: unique problem Pin
Stuart Dootson13-Aug-08 9:38
professionalStuart Dootson13-Aug-08 9:38 
If the order of elements is unimportant, sort the vector (with std::sort) before using unique.

Otherwise, try something like:

#include <set>
#include <vector>
#include <iostream>
#include <iterator>

struct Finder : std::unary_function<bool, int>
{
  Finder(std::set<int>& s) : s_(s) {}
  bool operator()(int i) const
  { 
    if (s_.count(i)==0)
    {
      s_.insert(i);
      return false;
    }
    else
    {
      return true;
    }
  }
  std::set<int>& s_;
};

int main(int, char**)
{
  std::vector<int> data;
  data.push_back(1);
  data.push_back(3);
  data.push_back(2);
  data.push_back(1);
  data.push_back(5);
  data.push_back(1);

  // Show the vector
  std::copy(data.begin(), data.end(), std::ostream_iterator<int>(std::cout, ", ")); std::cout << std::endl;
  
  // Use Finder and a set to remove items if we've seen them before in the vector
  std::set<int> uniqueItems;
  data.erase(std::remove_if(data.begin(), data.end(), Finder(uniqueItems)), data.end());

  // Show the vector with duplicates removed
  std::copy(data.begin(), data.end(), std::ostream_iterator<int>(std::cout, ", ")); std::cout << std::endl;
  return 0;
}


It's not too pretty, but should work OK. And if you parameterise Finder, you can re-use if you need to do it again
GeneralRe: unique problem Pin
s196675m13-Aug-08 18:07
s196675m13-Aug-08 18:07 
GeneralRe: unique problem Pin
Stephen Hewitt19-Aug-08 14:58
Stephen Hewitt19-Aug-08 14:58 
GeneralRe: unique problem Pin
Stuart Dootson19-Aug-08 19:39
professionalStuart Dootson19-Aug-08 19:39 
GeneralRe: unique problem Pin
Stephen Hewitt19-Aug-08 19:43
Stephen Hewitt19-Aug-08 19:43 
AnswerRe: unique problem Pin
Stephen Hewitt19-Aug-08 14:59
Stephen Hewitt19-Aug-08 14:59 
QuestionAccess Vector Objects by ID Pin
Alex H 19838-Aug-08 23:04
Alex H 19838-Aug-08 23:04 
AnswerRe: Access Vector Objects by ID Pin
Stuart Dootson9-Aug-08 13:27
professionalStuart Dootson9-Aug-08 13:27 
QuestionATL OLE document container problem Pin
Member 30621765-Aug-08 21:55
Member 30621765-Aug-08 21:55 
QuestionComboBox With ActiveX Control Pin
Dabara27-Jul-08 20:07
Dabara27-Jul-08 20:07 
QuestionUnable to retrieve data from safe array Pin
Debasis1021-Jul-08 1:12
Debasis1021-Jul-08 1:12 
AnswerRe: Unable to retrieve data from safe array Pin
Stuart Dootson23-Jul-08 11:25
professionalStuart Dootson23-Jul-08 11:25 
Questionhow to Registering namespace handlers for HTTP and HTTPS protocols within the Internet Explorer process ? Pin
ftbk20-Jul-08 23:02
ftbk20-Jul-08 23:02 
AnswerRe: how to Registering namespace handlers for HTTP and HTTPS protocols within the Internet Explorer process ? Pin
Stephen Hewitt24-Jul-08 20:44
Stephen Hewitt24-Jul-08 20:44 
Questionhow to capture go event of internet explorer in vc++6 Pin
skumar120920-Jul-08 21:40
skumar120920-Jul-08 21:40 
QuestionCompilatio error : cannot convert from char to LPWSTR Pin
V K 220-Jul-08 19:16
V K 220-Jul-08 19:16 
AnswerRe: Compilatio error : cannot convert from char to LPWSTR Pin
Stuart Dootson20-Jul-08 21:47
professionalStuart Dootson20-Jul-08 21:47 
QuestionPRJ0019 error when performing a registration Pin
chatko17-Jul-08 3:57
chatko17-Jul-08 3:57 

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.