Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bubble sort in CObList Pin
mesajflaviu14-Dec-10 21:15
mesajflaviu14-Dec-10 21:15 
GeneralRe: Bubble sort in CObList Pin
thomas.michaud15-Dec-10 3:35
thomas.michaud15-Dec-10 3:35 
AnswerRe: Bubble sort in CObList Pin
Eugen Podsypalnikov14-Dec-10 11:56
Eugen Podsypalnikov14-Dec-10 11:56 
GeneralRe: Bubble sort in CObList Pin
mesajflaviu14-Dec-10 21:14
mesajflaviu14-Dec-10 21:14 
AnswerRe: Bubble sort in CObList Pin
bleedingfingers14-Dec-10 20:27
bleedingfingers14-Dec-10 20:27 
AnswerRe: Bubble sort in CObList Pin
L. Braun14-Dec-10 21:16
L. Braun14-Dec-10 21:16 
GeneralRe: Bubble sort in CObList Pin
mesajflaviu14-Dec-10 23:59
mesajflaviu14-Dec-10 23:59 
AnswerRe: Bubble sort in CObList Pin
Michael Waters15-Dec-10 6:51
Michael Waters15-Dec-10 6:51 
If you are wedded to MFC, at least use a CObArray instead of a CObList. The algorithim will be much cleaner and faster with a smaller memory footprint.

For instance ...

typedef CTypedPtrArray<<CObArray, CDrawObj*>> CDrawObjArray;

then create the array ...
CDrawObjArray ObjArray;

const unsigned int nSize = 5;

ObjArray.SetSize(nSize);

fill the array ...
for(int i = 0; i < nSize; i++)
{
    CDrawObj* pObj = new CDrawObj(CRect(ptOrigin,sizeRect));
   
    ObjArray[i] = pObj;
}

and finally sort the array (using the most inefficient sorting algorithim known to man).
for(int i = 0; i < nSize; i++)
{
    for(int j = i; j < nSize; j++)
    {
        unsigned int nPrevious = ObjArray[j-1]->m_position.left;
        unsigned int nCurrent = ObjArray[j]->m_position.left;

        if(nPrevious > nCurrent)
        {
            CDrawObj* pObj = ObjArray[j-1];

            ObjArray[j-1] = ObjArray[j];
            ObjArray[j] = pObj ;
        }
    }
}


modified 17-Jan-19 15:57pm.

GeneralRe: Bubble sort in CObList Pin
David Crow15-Dec-10 7:59
David Crow15-Dec-10 7:59 
GeneralRe: Bubble sort in CObList Pin
mesajflaviu15-Dec-10 8:40
mesajflaviu15-Dec-10 8:40 
Questionhow to create line graph in vc++? Pin
mathivanaan13-Dec-10 17:25
mathivanaan13-Dec-10 17:25 
AnswerRe: how to create line graph in vc++? Pin
_AnsHUMAN_ 13-Dec-10 17:52
_AnsHUMAN_ 13-Dec-10 17:52 
AnswerRe: how to create line graph in vc++? Pin
RaviRanjanKr13-Dec-10 18:15
professionalRaviRanjanKr13-Dec-10 18:15 
AnswerRe: how to create line graph in vc++? Pin
Cedric Moonen13-Dec-10 20:18
Cedric Moonen13-Dec-10 20:18 
GeneralRe: how to create line graph in vc++? Pin
mathivanaan14-Dec-10 20:13
mathivanaan14-Dec-10 20:13 
AnswerRe: how to create line graph in vc++? Pin
basementman15-Dec-10 3:51
basementman15-Dec-10 3:51 
AnswerRe: how to create line graph in vc++? Pin
SoftwareDeveloperGoa15-Dec-10 9:50
SoftwareDeveloperGoa15-Dec-10 9:50 
QuestionVisulizing Webcam throught browser Pin
Schehaider_Aymen13-Dec-10 8:51
Schehaider_Aymen13-Dec-10 8:51 
AnswerRe: Visulizing Webcam throught browser Pin
Cool_Dev14-Dec-10 1:41
Cool_Dev14-Dec-10 1:41 
GeneralRe: Visulizing Webcam throught browser Pin
Schehaider_Aymen16-Dec-10 10:37
Schehaider_Aymen16-Dec-10 10:37 
GeneralRe: Visulizing Webcam throught browser Pin
Cool_Dev16-Dec-10 17:21
Cool_Dev16-Dec-10 17:21 
GeneralRe: Visulizing Webcam throught browser Pin
Schehaider_Aymen20-Dec-10 11:20
Schehaider_Aymen20-Dec-10 11:20 
GeneralRe: Visulizing Webcam throught browser Pin
Cool_Dev20-Dec-10 17:12
Cool_Dev20-Dec-10 17:12 
QuestionCListCtrl & theCtrl = GetListCtrl Pin
cy163@hotmail.com13-Dec-10 4:07
cy163@hotmail.com13-Dec-10 4:07 
AnswerRe: CListCtrl & theCtrl = GetListCtrl Pin
David Crow13-Dec-10 4:36
David Crow13-Dec-10 4: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.