Click here to Skip to main content
15,913,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: convert visual c++ project in to complete sw........ Pin
Jijo.Raj1-Sep-08 20:26
Jijo.Raj1-Sep-08 20:26 
GeneralRe: convert visual c++ project in to complete sw........ Pin
Rane1-Sep-08 20:56
Rane1-Sep-08 20:56 
GeneralRe: convert visual c++ project in to complete sw........ Pin
Jijo.Raj1-Sep-08 21:50
Jijo.Raj1-Sep-08 21:50 
QuestionSend SMS Pin
Paulraj G1-Sep-08 19:41
Paulraj G1-Sep-08 19:41 
AnswerRe: Send SMS Pin
mdsameerahsan1-Sep-08 20:45
mdsameerahsan1-Sep-08 20:45 
GeneralRe: Send SMS Pin
Paulraj G1-Sep-08 20:51
Paulraj G1-Sep-08 20:51 
AnswerRe: Send SMS Pin
Hamid_RT1-Sep-08 22:29
Hamid_RT1-Sep-08 22:29 
Questionslow std::sort, hot to make it without object copy? Pin
Michele Bosi1-Sep-08 19:39
Michele Bosi1-Sep-08 19:39 
I have a vector of millions of points that I have to sort based on their distance from the camera, in order to do that i created the following simple function object:

    class PointSorter
    {
    public:
      PointSorter()
      {
        points = NULL;
      }

      // !!! copy constructor called all the time during std::sort !!!
      PointSorter(const PointSorter& other)
      {
        points = other.points;
        printf("object copied");
      }

      PointSorter(std::vector<vl::fvec3 xmlns:vl="#unknown">* pvec==NULL)
      {
        points = pvec;
      }

      bool operator()(const unsigned int&a, const unsigned int&b)
      {
         return (*points)[a].z() < (*points)[b].z();
      }

      std::vector<vl::fvec3>* points;
    };
</vl::fvec3></vl::fvec3>

then later on I do a simple

    PointSorter sorter(&mypoints);
    // std::vector<int> indices;
    std::sort( indices.begin(), indices.end(), sorter );
</int>

this sorts the indices of my points well, the only concern is that I discovered that the object "sorter" is being copied all the time during std::sort, this shurely impact negatively the sorting performance which is already quite poor for millions of points since I have to achieve interactive frame rates for my 3d program.

Does anyone know how to pass a custom sorter object (which is not a static function) that is copied once and used all the way throughout the sorting?

Regards,
Michele
AnswerRe: slow std::sort, hot to make it without object copy? Pin
Dracula Wang1-Sep-08 20:06
Dracula Wang1-Sep-08 20:06 
Questionhow can i get the boot volume drive letter Pin
Dracula Wang1-Sep-08 19:33
Dracula Wang1-Sep-08 19:33 
QuestionBlank date in CDateTimeCtrl !! Pin
Le@rner1-Sep-08 19:32
Le@rner1-Sep-08 19:32 
AnswerRe: Blank date in CDateTimeCtrl !! Pin
_AnsHUMAN_ 1-Sep-08 20:06
_AnsHUMAN_ 1-Sep-08 20:06 
GeneralRe: Blank date in CDateTimeCtrl !! Pin
Le@rner3-Sep-08 1:13
Le@rner3-Sep-08 1:13 
QuestionHow to handle TerminateProcess in my Application? Pin
Erik1-Sep-08 18:49
Erik1-Sep-08 18:49 
AnswerRe: How to handle TerminateProcess in my Application? Pin
onlyjaypatel1-Sep-08 19:13
onlyjaypatel1-Sep-08 19:13 
AnswerRe: How to handle TerminateProcess in my Application? Pin
JudyL_MD2-Sep-08 6:32
JudyL_MD2-Sep-08 6:32 
QuestionString to char* Pin
Shirani1-Sep-08 17:28
Shirani1-Sep-08 17:28 
AnswerRe: String to char* Pin
Rane1-Sep-08 18:01
Rane1-Sep-08 18:01 
GeneralRe: String to char* Pin
ThatsAlok1-Sep-08 20:16
ThatsAlok1-Sep-08 20:16 
AnswerRe: String to char* Pin
santhoshv841-Sep-08 18:23
santhoshv841-Sep-08 18:23 
AnswerRe: String to char* Pin
onlyjaypatel1-Sep-08 19:00
onlyjaypatel1-Sep-08 19:00 
GeneralRe: String to char* Pin
Cedric Moonen1-Sep-08 19:56
Cedric Moonen1-Sep-08 19:56 
AnswerRe: String to char* Pin
Cedric Moonen1-Sep-08 20:00
Cedric Moonen1-Sep-08 20:00 
GeneralRe: String to char* Pin
ThatsAlok1-Sep-08 20:17
ThatsAlok1-Sep-08 20:17 
AnswerRe: String to char* Pin
ThatsAlok1-Sep-08 20:15
ThatsAlok1-Sep-08 20:15 

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.