@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15



Comments:

<0> lol
<1> he cant see his toes anymore
<2> Cowmoo, merry easter
<3> go away
<3> you caused me a lot of stress last nighjt
<3> I have a weak hear
<3> t
<2> haha
<4> cowmoo, was the *** that good?
<3> stfu
<4> OH SNAP
<5> if i get a string bu char [] do i have release the memory after that or not >
<3> qqqqqqq: rephrase in english, pls thx
<4> bees are on the what now?
<1> eh and the english for that is?



<6> how can i use the virtual heritage
<6> ?
<2> Cowmoo gets stressed easily qqqqqqq, you have to tailor your questions to his needs to as to avoid possible health risks on his part
<2> so*
<1> wtf is virtual heritage...old buildings and stuff?
<3> xeagle: erm, inheritance?
<6> yes
<3> we're not going to sit here and explain it all to you...you're going to have to ask a specific question, or learn from a book
<5> if i get by func(char ch[]) when the function end do i have to release ch[] ?
<6> just need the syntax
<5> ?
<1> that depends on many things...like how you call the function
<7> qqqqqqq: Is the memory dynamically allocated for your char[] or do you specify a constant value for it
<5> func("my name");
<3> also how about using std::string instead of tossing about with char arrays
<3> I see the word tossing caused you excitement
<1> tossing is good
<3> haha
<1> tosser :)
<3> heh
<1> you must be a brit so...
<3> I'm not
<1> ohh..you understand english too...
<3> but was taught english by them
<1> <grin>
<3> (for the record I'm not form an english-speaking country, heh, just make trips to the UK every year)
<1> where you from then?
<3> far
<3> away
<1> as in star wars?
<3> might as well be, yes
<3> Oman
<1> ahhh
<1> now i see the brit connection :)
<3> haha
<8> nth_element(a, b, c) creates a partial sort that arranges elements less than *b before b, and greater than *b after b..
<8> is there a quick way to get the 2nd element?
<0> oh
<0> there should be a find-sorta method that doesn't mutate the range
<8> nth_element is like something u'd use in building your own qsort
<8> but then, there's std::sort for that
<0> maybe find_nth or something... I don't have my Josuttis book handy
<8> i was thinking about using max_element to find the largest elem. removing it. then applying max_element N times to find the real nth element
<8> but this is stupid
<8> might as well sort the damn thing
<0> nth_element ?
<0> hmm
<0> nth_element mutates? does max_element mutate?
<8> oh. was that a rhetoric question
<8> i'm trying to get the 2nd element
<8> like.. without doing any actual work
<0> yeah I know
<8> lol
<0> there's got to be an algorithm in there that does it
<1> 2nd element of what?
<8> i have an unsorted list
<8> and i want a quick way to find the 2nd largest element in the list
<8> i could write a functor using for_each..
<8> but max_element worked so well i was wondering if there's a 2nd_max_element or something



<1> .begin() +1
<1> 2nd largest..
<8> that gives me the 2nd element alright, but i want the 2nd largest
<1> just sort it
<8> that would be n log n time.. if i could get the 2nd largest using an n time algorithm
<8> just traverse and keep a backup copy of the previous runner up
<0> just use nth_element to do a partial sort
<0> i think that's the most straightforward way
<0> otherwise, it would be two linear searches
<8> ok, so what do i put as the pivot term
<0> what?
<1> theres always binary_serch
<0> well, it would have to be sorted for that to work
<8> for nth_element. it requires a middle term for dividing the set into 2 groups, one side larger, one side smaller
<1> if you already have it sorted
<8> binary_search requires a sorted list..
<8> yeah
<0> dextre1 the 'pivot' is the one you're looking for
<3> nth element won't work for what you want to do dextre1
<0> sure it will
<3> really?
<0> basically it sorts up to the nth element in the range
<0> doesn't sort the whole thing
<3> what
<8> HMM
<1> it mutates the container tho
<3> I thought it does a partition
<8> yeah i thought so too
<3> yea from reading description sounds liek a parition to me, not a sort of any kind
<0> nth_element( vec.begin(), vec.begin() + 1, vec.end() ); //after this, the 1st and 2nd elements will be the smallest 2 elements in the range
<0> er, yeah, it does a partition
<0> but he's looking for the 2nd in the range
<3> wait what?
<3> how do they end up being smallest 2
<3> I confused
<0> what do you think it does?
<0> Nth_element is similar to partial_sort, in that it partially orders a range of elements: it arranges the range [first, last) such that the element pointed to by the iterator nth is the same as the element that would be in that position if the entire range [first, last) had been sorted. Additionally, none of the elements in the range [nth, last) is less than any of the elements in the range [first, nth).
<3> it just reorganises such that .begin() + 1 is now positioned so that everything before it is < than it and everuthing after it is > than it
<0> exactly
<3> i.e. partitions, where that is your piviot
<0> so, .begin() will point to the smallest element, .begin() + 1 will point to the 2nd smallest
<3> wait
<1> you'll need a copy of the container
<3> no?
<0> just read it
<3> haha ok hang on
<0> gotta take a shower
<1> if the container is required later
<8> so .. which side of the partition becomes sorted? the example on the STL reference seems to hint at the right partition being sorted
<0> each side is partially sorted
<0> so that everything less than nth is to the left, everything greater is to the right
<3> ohhhh
<3> okok ya rdragon, my mistake
<8> so it's not guaranteed sorted on either side
<0> i don't think so dextre1 - but like I said, I don't have my Josuttis book handy, i just checked sgi.com
<1> after nth will contain the required "value"#
<0> back later
<3> dextre1: yes, it won't be sorted on eieher side
<8> unless, in my case, if i use nth_element(L.begin(),L.begin()+1,L.end()), it's a special case where the first 2 elements will be ordered correctly.. since the min element is right before the pivot....... i think
<8> yeah, i'm reading sgi.com , that example is misleading
<0> it's not a 'special case', it's simply the only thing that could be true for it to work
<8> yeah
<3> cppreference.com is horribly misleading there too
<0> if everything to the left must be less, and there's only one element there, well....
<8> is nth_element something no one uses?
<0> you can use it
<1> play with it
<0> it does what you want
<1> and see:)
<0> and someone wrote it, soo ;)
<8> and what do you mean when u say it "mutates" the list?
<8> that it changes the list?
<1> yes
<8> o


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #c++
or
Go to some related logs:

#MissKitten
libdivxdecore ubuntu
diff'rent strokes chilean
IN 1964 RHODESIA DECLARED UDI, WHAT IS 'UDI'?
xcelent2005
#linux
#skype
nj-mysql-###.uplinkearth.com
#AllNiteCafe
#c++



Home  |  disclaimer  |  contact  |  submit quotes