I want to create a list,
each element is an array of 2 integers,
and I want to sort the list according to the first integer of each
element,
is there a simple way to do this? thanks a lot. 3 1298
On Mar 29, 9:20 am, Atemporal <Atemporal.s...@gmail.comwrote:
Just break down what you said...
I want to create a list,
OK... std::list<Nmylist;
each element is an array of 2 integers,
OK... std::list< boost::array<int,2 myList (or whatever array
structure you like if you don't have the boost library)
and I want to sort the list according to the first integer of each
element,
std::sort(myList, accordingToTheFirstInteger);
bool accordingToTheFirstInteger(boost::array<int,2>& x,
boost::array<int,2>& y)
{
// Put how you want to sort them here. (Odd first, then even? OR
largest to smallest)
// See http://msdn2.microsoft.com/en-us/lib...h1(VS.80).aspx
}
is there a simple way to do this? thanks a lot.
joseph cook wrote:
On Mar 29, 9:20 am, Atemporal <Atemporal.s...@gmail.comwrote:
Just break down what you said...
>I want to create a list,
OK... std::list<Nmylist;
>each element is an array of 2 integers,
OK... std::list< boost::array<int,2 myList (or whatever array
structure you like if you don't have the boost library)
>and I want to sort the list according to the first integer of each element,
std::sort(myList, accordingToTheFirstInteger);
bool accordingToTheFirstInteger(boost::array<int,2>& x,
boost::array<int,2>& y)
{
// Put how you want to sort them here. (Odd first, then even? OR
largest to smallest)
// See http://msdn2.microsoft.com/en-us/lib...h1(VS.80).aspx
}
>is there a simple way to do this? thanks a lot.
An even simpler way would be
std::map<int, intData;
--
Jim Langston ta*******@rocketmail.com
std::sort(myList, accordingToTheFirstInteger);
Of course i intended to type
std::sort(myList.begin(), myList.end(), accordingToTheFirstInteger). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Roy Riddex |
last post by:
2nd post of the day! I'm just learning about Arrays at College and have met
a problem. I have 5 text boxes for number input, a command button to add the
numbers to the array, and a command button...
|
by: jrlen balane |
last post by:
basically what the code does is transmit data to a hardware and then
receive data that the hardware will transmit.
import serial
import string
import time
from struct import *
ser =...
|
by: jmac |
last post by:
Greetings fellow programmers,
I have created a C program that has a few bugs and would like to get
some help with working them out. Here is a list of the problems that
I am experiencing:
-...
|
by: Rob Somers |
last post by:
Hey all
I am writing a program to keep track of expenses and so on - it is not
a school project, I am learning C as a hobby - At any rate, I am new
to structs and reading and writing to files,...
|
by: Alan |
last post by:
hi all,
I want to define a constant length string, say 4
then in a function at some time, I want to set the string to a constant
value, say a
below is my code but it fails
what is the correct...
| |
by: Ross A. Finlayson |
last post by:
I'm trying to write some C code, but I want to use C++'s std::vector.
Indeed, if the code is compiled as C++, I want the container to
actually be std::vector, in this case of a collection of value...
|
by: Claudio Grondi |
last post by:
In the process of learning about some deeper details of Python I am
curious if it is possible to write a 'prefix' code assigning to a and b
something special, so, that Python gets trapped in an...
|
by: learnfpga |
last post by:
Here is a little code I wrote to add the numbers input by the
user.....I was wondering if its possible to have the same functionality
without using dynamic arrays.....just curious.....
...
|
by: Michael |
last post by:
Hi,
I am trying to pass a function an array of strings, but I am having trouble
getting the indexing to index the strings rather than the individual
characters of one of the strings.
I have...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |