Erik Wikström
11/23/2008 10:27:00 AM
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