Click here to Skip to main content
16,016,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: API for changing Language for non-Unicode Programs???? Pin
Rajesh R Subramanian22-Jun-09 1:59
professionalRajesh R Subramanian22-Jun-09 1:59 
GeneralRe: API for changing Language for non-Unicode Programs???? Pin
Super Hornet22-Jun-09 2:03
Super Hornet22-Jun-09 2:03 
AnswerRe: API for changing Language for non-Unicode Programs???? Pin
Nemanja Trifunovic22-Jun-09 6:04
Nemanja Trifunovic22-Jun-09 6:04 
QuestionHow to add data to sorted vector? Pin
alikalik22-Jun-09 1:32
alikalik22-Jun-09 1:32 
AnswerRe: How to add data to sorted vector? Pin
CPallini22-Jun-09 1:55
mveCPallini22-Jun-09 1:55 
AnswerRe: How to add data to sorted vector? Pin
Rajesh R Subramanian22-Jun-09 1:55
professionalRajesh R Subramanian22-Jun-09 1:55 
GeneralRe: How to add data to sorted vector? Pin
alikalik22-Jun-09 2:14
alikalik22-Jun-09 2:14 
AnswerRe: How to add data to sorted vector? Pin
Stuart Dootson22-Jun-09 2:32
professionalStuart Dootson22-Jun-09 2:32 
Depends on the usage patterns. If the number of lookups is significantly higher than the number of inserts, then I'd just use a sorted vector (as my experiences indicate that a binary search on a sorted vector is significantly faster than use of STL's associative containers in C++). If inserts are more significant than that, use a std::multiset as suggested elsewhere.

If using a sorted vector, it helps to delay the sort operation until required, using something like below, rather than blindly sorting on every insert.

template<class Type>
class SortedVector
{
public:
   SortedVector() sorted_(true) {}
   void insert(Type const& value)
   {
      sorted_ = false;
      data_.push_back(value);
   }
   typename std::vector<Type>::const_iterator find(Type const& value) const
   {
      if (!sorted_)
      {
         std::sort(data_.begin(), data_.end());
         sorted_ = true;
      }
      std::vector<Type>::const_iterator found = 
            std::lower_bound(data_.begin(), data_.end(), value);
      return (*found == value)?found:data_.end();
   }
private:
   mutable bool sorted_;
   mutable std::vector<Type> data_;
};


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

Questionoverriding CDialog::Create Pin
p_196022-Jun-09 0:03
p_196022-Jun-09 0:03 
AnswerRe: overriding CDialog::Create Pin
«_Superman_»22-Jun-09 0:38
professional«_Superman_»22-Jun-09 0:38 
GeneralRe: overriding CDialog::Create Pin
p_196022-Jun-09 1:01
p_196022-Jun-09 1:01 
GeneralRe: overriding CDialog::Create Pin
Stuart Dootson22-Jun-09 2:36
professionalStuart Dootson22-Jun-09 2:36 
AnswerRe: overriding CDialog::Create Pin
Member 348023222-Jun-09 1:03
Member 348023222-Jun-09 1:03 
Questionhow to transparent MFC activeX control Pin
B060611521-Jun-09 23:44
B060611521-Jun-09 23:44 
AnswerRe: how to transparent MFC activeX control Pin
Member 348023222-Jun-09 1:07
Member 348023222-Jun-09 1:07 
GeneralRe: how to transparent MFC activeX control Pin
B060611522-Jun-09 18:43
B060611522-Jun-09 18:43 
AnswerRe: how to transparent MFC activeX control Pin
Member 348023222-Jun-09 23:02
Member 348023222-Jun-09 23:02 
GeneralRe: how to transparent MFC activeX control Pin
B060611523-Jun-09 0:16
B060611523-Jun-09 0:16 
AnswerRe: how to transparent MFC activeX control Pin
Member 348023223-Jun-09 4:34
Member 348023223-Jun-09 4:34 
QuestionProblem in output Pin
Gjm21-Jun-09 23:27
Gjm21-Jun-09 23:27 
AnswerRe: Problem in output Pin
CPallini21-Jun-09 23:32
mveCPallini21-Jun-09 23:32 
AnswerRe: Problem in output Pin
Fatbuddha 122-Jun-09 2:01
Fatbuddha 122-Jun-09 2:01 
QuestionRe: Problem in output Pin
David Crow22-Jun-09 3:44
David Crow22-Jun-09 3:44 
Question[Message Deleted] Pin
jitendrapothuru21-Jun-09 22:15
jitendrapothuru21-Jun-09 22:15 
AnswerRe: multiple comport settings to be taken Pin
chandu00421-Jun-09 22:30
chandu00421-Jun-09 22:30 

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.