Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Sorting an Array of double

Reply
Thread Tools

Sorting an Array of double

 
 
Luca Risolia
Guest
Posts: n/a
 
      05-29-2013
Jorgen Grahn wrote:

> Luca suggested
>
> std::sort(std::begin(Tx), std::begin(Tx) + Ttotal);
>
> Well, I don't know what std::begin does -- is it a C++11 thing, or
> something in C++98 I simply missed? Perhaps it's better.


The above statement is more general as it can sort any standard container
providing Random Access Iterators. In facts, std::begin() is a new function
template introduced in C++11 which returns an iterator to the beginning of the
container or array passed as argument. It has no overhead on performance as
the call can be optimized out by any compiler.

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      05-29-2013
Luca Risolia wrote:
> Jorgen Grahn wrote:
>
>> Luca suggested
>>
>> std::sort(std::begin(Tx), std::begin(Tx) + Ttotal);
>>
>> Well, I don't know what std::begin does -- is it a C++11 thing, or
>> something in C++98 I simply missed? Perhaps it's better.

>
> The above statement is more general as it can sort any standard container
> providing Random Access Iterators. In facts, std::begin() is a new function
> template introduced in C++11 which returns an iterator to the beginning of the
> container or array passed as argument. It has no overhead on performance as
> the call can be optimized out by any compiler.


Thanks for pointing it out, I'd missed that one!

--
Ian Collins
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Array objects get changed when sorting the array Roedy Green Java 1 06-25-2009 08:25 PM
Re: Array objects get changed when sorting the array markspace Java 1 06-25-2009 06:22 PM
sorting of double[][]based on a double[] jimgardener Java 3 07-11-2008 08:51 PM
is it safe to access a complex<double> array as a double array oftwice the length? huili80@gmail.com C++ 5 06-27-2008 11:13 AM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM



Advertisments