Click here to Skip to main content
15,886,362 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: windows Visual Studio C++/Visual Basic file locking Pin
Cool_Dev28-Aug-10 3:12
Cool_Dev28-Aug-10 3:12 
AnswerRe: windows Visual Studio C++/Visual Basic file locking Pin
cmk30-Aug-10 18:28
cmk30-Aug-10 18:28 
QuestionActiveX without prompting? (or how to create an IE-plugin?) Pin
Don Rolando15-Aug-10 20:44
Don Rolando15-Aug-10 20:44 
AnswerRe: ActiveX without prompting? (or how to create an IE-plugin?) Pin
Cool_Dev28-Aug-10 3:00
Cool_Dev28-Aug-10 3:00 
QuestionC++ MFC - DatePickerControl - DTN_DATETIMECHANGE event getting triggered twice when clicked !!!! [modified] Pin
Kausik4u11-Aug-10 8:54
Kausik4u11-Aug-10 8:54 
AnswerRe: C++ MFC - DatePickerControl - DTN_DATETIMECHANGE event getting triggered twice when clicked !!!! Pin
Stuart Dootson12-Aug-10 4:17
professionalStuart Dootson12-Aug-10 4:17 
GeneralRe: C++ MFC - DatePickerControl - DTN_DATETIMECHANGE event getting triggered twice when clicked !!!! Pin
Kausik4u12-Aug-10 4:27
Kausik4u12-Aug-10 4:27 
QuestionTranlating old code to the STL style Pin
VeganFanatic8-Aug-10 4:47
VeganFanatic8-Aug-10 4:47 
OK I found a sort algorithm on Wikipedia, that is done like the std::sort so I figured why not convert the who lot that I have to STL. Blah.

First the new sort

template<class ForwardIterator> void comb(ForwardIterator first, ForwardIterator last){
    static const double shrink_factor = 1.247330950103979;
    typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
    difference_type gap = std::distance(first, last);
    bool swaps = true;
    while ( (gap > 1) || (swaps == true) ){
        if (gap > 1)
            gap = static_cast<difference_type>(gap/shrink_factor);
        swaps = false;
        ForwardIterator itLeft(first);
        ForwardIterator itRight(first); std::advance(itRight, gap);
        for ( ; itRight!=last; ++itLeft, ++itRight ){
            if ( (*itRight) < (*itLeft) ){
                std::iter_swap(itLeft, itRight);
                swaps = true;
            }
        }
    }
}


So now the old bubble sort

template <typename T> void bubble(std::vector<T> &a) { // O(n^2)
	size_t size = a.size() - 1;
    for (int pass = 0; pass < size; pass++) {
		for (int n = 0; n < size; n++) {
			if (a[n] > a[n+1])
				std::swap(a[n], a[n+1]);
        }
    }
}


and this is as far as I have gone so far

template<class ForwardIterator> void bubble(ForwardIterator first, ForwardIterator last){
    typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
    difference_type size = std::distance(first, last);
}

http://www.contract-developer.tk

AnswerRe: Tranlating old code to the STL style Pin
Stuart Dootson12-Aug-10 4:13
professionalStuart Dootson12-Aug-10 4:13 
GeneralRe: Tranlating old code to the STL style Pin
VeganFanatic12-Aug-10 8:33
VeganFanatic12-Aug-10 8:33 
GeneralRe: Tranlating old code to the STL style Pin
Stuart Dootson12-Aug-10 8:51
professionalStuart Dootson12-Aug-10 8:51 
GeneralRe: Tranlating old code to the STL style Pin
VeganFanatic12-Aug-10 8:56
VeganFanatic12-Aug-10 8:56 
GeneralRe: Tranlating old code to the STL style Pin
Stuart Dootson12-Aug-10 9:16
professionalStuart Dootson12-Aug-10 9:16 
GeneralRe: Tranlating old code to the STL style Pin
VeganFanatic12-Aug-10 9:20
VeganFanatic12-Aug-10 9:20 
QuestionATL: WM_MOUSELEAVE Pin
Supriya Tonape6-Aug-10 4:30
Supriya Tonape6-Aug-10 4:30 
AnswerRe: ATL: WM_MOUSELEAVE Pin
Frank Seidler6-Aug-10 4:38
Frank Seidler6-Aug-10 4:38 
GeneralRe: ATL: WM_MOUSELEAVE Pin
Sauro Viti6-Aug-10 4:46
professionalSauro Viti6-Aug-10 4:46 
GeneralRe: ATL: WM_MOUSELEAVE Pin
Supriya Tonape9-Aug-10 2:25
Supriya Tonape9-Aug-10 2:25 
GeneralRe: ATL: WM_MOUSELEAVE Pin
Supriya Tonape9-Aug-10 2:28
Supriya Tonape9-Aug-10 2:28 
QuestionHow can my CDerivedEdit respond WM_SHOWWINDOW? (OnShowWindow) Pin
dancingfish5-Aug-10 21:41
dancingfish5-Aug-10 21:41 
QuestionAuthentication client-server using message queues in c language Pin
ralph 230-Jul-10 2:31
ralph 230-Jul-10 2:31 
AnswerRe: Authentication client-server using message queues in c language Pin
Richard MacCutchan30-Jul-10 3:17
mveRichard MacCutchan30-Jul-10 3:17 
GeneralRe: Authentication client-server using message queues in c language Pin
ralph 230-Jul-10 3:20
ralph 230-Jul-10 3:20 
QuestionProgressBar and Threading.. Pin
Anil Kumar.Arvapalli29-Jul-10 19:53
Anil Kumar.Arvapalli29-Jul-10 19:53 
AnswerRe: ProgressBar and Threading.. Pin
Richard MacCutchan29-Jul-10 22:24
mveRichard MacCutchan29-Jul-10 22:24 

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.