1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // AliMp::Pair functions:
19 // The functions for encoding the pair of integers to another integer,
20 // defined withing a namespace AliMp.
21 // The encoded pairs can be added and subtracted.
22 // Author Laurent Aphecetche
24 #include "AliMpEncodePair.h"
26 #include <Riostream.h>
28 //_______________________________________________________________________
29 MpPair_t AliMp::Pair(Int_t first, Int_t second)
31 /// See also AliMp::PairFirst(), AliMp::PairSecond()
32 /// \author L. Aphecetche, SUBATECH
34 return (( first << 16 ) | second);
37 //_______________________________________________________________________
38 Int_t AliMp::PairFirst(MpPair_t pair )
40 /// See also AliMp::Pair(), AliMp::PairSecond()
41 /// \author L. Aphecetche, SUBATECH
43 return ( pair & 0xFFFF0000 ) >> 16;
46 //_______________________________________________________________________
47 Int_t AliMp::PairSecond(MpPair_t pair)
49 /// See also AliMp::Pair(), AliMp::PairFirst()
50 /// \author L. Aphecetche, SUBATECH
55 //_______________________________________________________________________
56 ostream& AliMp::PairPut(ostream& stream, MpPair_t pair)
58 /// A special printing for encoded pair.
61 stream << '(' << AliMp::PairFirst(pair)
62 << ',' << AliMp::PairSecond(pair) << ')';
66 stream << "AliMpIntPair::Invalid";