[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Joy Maitland

11/23/2008 6:02:00 AM

I have an imageID and a pair of (X,Y) coordinate

how can I map( X,Y) coordinate as a key to imageID?

for example

(1,1) -> image1
(2,1) -> image5
(5,4) -> image12
(1,9) -> image8
.... etc

what Class object i should use?
any example code ?
4 Answers

Kai-Uwe Bux

11/23/2008 6:33:00 AM

0

Joy Maitland wrote:

> I have an imageID and a pair of (X,Y) coordinate
>
> how can I map( X,Y) coordinate as a key to imageID?
>
> for example
>
> (1,1) -> image1
> (2,1) -> image5
> (5,4) -> image12
> (1,9) -> image8
> ... etc
>
> what Class object i should use?
[snip]

What about:

typedef int x_coordinate;
typedef int y_coordinate;

typedef std::pair< x_coordinate, y_coordinate > cartesian_2d;
typedef std::map< cartesian_2d, imageID > image_map;



Best

Kai-Uwe Bux

Joy Maitland

11/23/2008 7:46:00 AM

0

On Sun, 23 Nov 2008 01:33:12 -0500, Kai-Uwe Bux <jkherciueh@gmx.net>
wrote:

>Joy Maitland wrote:
>
>> I have an imageID and a pair of (X,Y) coordinate
>>
>> how can I map( X,Y) coordinate as a key to imageID?
>>
>> for example
>>
>> (1,1) -> image1
>> (2,1) -> image5
>> (5,4) -> image12
>> (1,9) -> image8
>> ... etc
>>
>> what Class object i should use?
>[snip]
>
>What about:
>
> typedef int x_coordinate;
> typedef int y_coordinate;
>
> typedef std::pair< x_coordinate, y_coordinate > cartesian_2d;
> typedef std::map< cartesian_2d, imageID > image_map;
>

do i use these template lke this:

cartesian_2d coord1 = (1,2);
cartesian_2d coord2 = (3,2);

image_map map1;
map1.add(coord1, 1);
map1.add(coord2, 3);

>
>
>Best
>
>Kai-Uwe Bux

Erik Wikström

11/23/2008 10:27:00 AM

0

On 2008-11-23 08:46, Joy Maitland wrote:
> On Sun, 23 Nov 2008 01:33:12 -0500, Kai-Uwe Bux <jkherciueh@gmx.net>
> wrote:
>
>>Joy Maitland wrote:
>>
>>> I have an imageID and a pair of (X,Y) coordinate
>>>
>>> how can I map( X,Y) coordinate as a key to imageID?
>>>
>>> for example
>>>
>>> (1,1) -> image1
>>> (2,1) -> image5
>>> (5,4) -> image12
>>> (1,9) -> image8
>>> ... etc
>>>
>>> what Class object i should use?
>>[snip]
>>
>>What about:
>>
>> typedef int x_coordinate;
>> typedef int y_coordinate;
>>
>> typedef std::pair< x_coordinate, y_coordinate > cartesian_2d;
>> typedef std::map< cartesian_2d, imageID > image_map;
>>
>
> do i use these template lke this:
>
> cartesian_2d coord1 = (1,2);
> cartesian_2d coord2 = (3,2);

No, you have to use the make_pair() function:

cartesian_2d coord1 = make_pair(1,2);
cartesian_2d coord2 = make_pair(3,2);

> image_map map1;
> map1.add(coord1, 1);
> map1.add(coord2, 3);

--
Erik Wikström

Juha Nieminen

11/23/2008 2:19:00 PM

0

Erik Wikström wrote:
> cartesian_2d coord1 = make_pair(1,2);
> cartesian_2d coord2 = make_pair(3,2);

What's wrong with:

cartesian_2d coord1(1, 2);
cartesian_2d coord2(3, 2);

?