Imported Upstream version 0.12.7
[bowtie.git] / SeqAn-1.1 / seqan / basic / basic_aggregates.h
1  /*==========================================================================
2                 SeqAn - The Library for Sequence Analysis
3                           http://www.seqan.de 
4  ============================================================================
5   Copyright (C) 2007
6
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public
9   License as published by the Free Software Foundation; either
10   version 3 of the License, or (at your option) any later version.
11
12   This library is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   Lesser General Public License for more details.
16
17  ============================================================================
18   $Id: basic_aggregates.h,v 1.1 2008/08/25 16:20:01 langmead Exp $
19  ==========================================================================*/
20
21 #ifndef SEQAN_HEADER_BASIC_AGGREGATES_H
22 #define SEQAN_HEADER_BASIC_AGGREGATES_H
23
24 namespace SEQAN_NAMESPACE_MAIN
25 {
26
27 //____________________________________________________________________________
28
29     struct _Compressed;
30         typedef Tag<_Compressed> Compressed;
31
32         // for Pairs with small i1-values
33         // store i1 and i2 in one word of type i2
34         // use the upper bits for i1 and the lower bits for i2
35         template <unsigned valueSizeI1 = 16>
36         struct CutCompressed {
37                 enum { bitSizeI1 = Log2<valueSizeI1>::VALUE };
38         };
39
40 /**
41 .Class.Pair:
42 ..cat:Aggregates
43 ..summary:Stores two arbitrary objects.
44 ..signature:Pair<T1, T2[, Compression]>
45 ..param.T1:The type of the first object.
46 ..param.T2:The type of the second object.
47 ..param.Compression:If $Compressed$, the pair is stored in a more space efficient way (useful for external storage).
48 ...note:When compression is enabled, referring to members is not allowed.
49 ...default:$void$, no compression (faster access).
50 .Memfunc.Pair#Pair:
51 ..class:Class.Pair
52 ..summary:Constructor
53 ..signature:Pair<T1, T2> ()     
54 ..signature:Pair<T1, T2> (pair)
55 ..signature:Pair<T1, T2> (i1, i2)
56 ..param.pair:Other Pair object. (copy constructor)
57 ..param.i1:T1 object.
58 ..param.i2:T2 object.
59 .Memvar.Pair#i1:
60 ..class:Class.Pair
61 ..summary:T1 object
62 .Memvar.Pair#i2:
63 ..class:Class.Pair
64 ..summary:T2 object
65 */
66
67         // standard storage 
68         template <typename _T1, typename _T2 = _T1, typename TCompression = void>
69     struct Pair {
70         typedef _T1 T1;
71         typedef _T2 T2;
72             _T1 i1;
73             _T2 i2;
74                 inline Pair() {}
75                 inline Pair(Pair const &_p): i1(_p.i1), i2(_p.i2) {}
76                 inline Pair(_T1 const &_i1, _T2 const &_i2): i1(_i1), i2(_i2) {}
77
78                 template <typename __T1, typename __T2, typename __TCompression>
79                 inline Pair(Pair<__T1, __T2, __TCompression> const &_p):
80                         i1(getValueI1(_p)), i2(getValueI2(_p)) {}
81     };
82
83
84
85         // unaligned and unpadded storage (space efficient)
86 #ifdef PLATFORM_WINDOWS
87     #pragma pack(push,1)
88 #endif
89     template <typename _T1, typename _T2>
90     struct Pair<_T1, _T2, Compressed> {
91         typedef _T1 T1;
92         typedef _T2 T2;
93         _T1 i1;
94         _T2 i2;
95                 inline Pair() {}
96                 inline Pair(Pair const &_p): i1(_p.i1), i2(_p.i2) {}
97                 inline Pair(_T1 const &_i1, _T2 const &_i2): i1(_i1), i2(_i2) {}
98
99                 template <typename __T1, typename __T2, typename __TCompression>
100                 inline Pair(Pair<__T1, __T2, __TCompression> const &_p):
101                         i1(getValueI1(_p)), i2(getValueI2(_p)) {}
102         }
103 #ifndef PLATFORM_WINDOWS
104         __attribute__((packed))
105 #endif
106         ;
107 #ifdef PLATFORM_WINDOWS
108     #pragma pack(pop)
109 #endif
110
111
112
113 #ifdef PLATFORM_WINDOWS
114     #pragma pack(push,1)
115 #endif
116     template <typename _T1, typename _T2, unsigned valueSizeI1>
117     struct Pair<_T1, _T2, CutCompressed<valueSizeI1> > {
118         typedef _T1 T1;
119         typedef _T2 T2;
120
121                 typedef _T2 T12;
122
123         T12 i12;
124
125                 enum { bitSizeI1 = CutCompressed<valueSizeI1>::bitSizeI1 };
126         enum { bitShiftI1 = BitsPerValue<T12>::VALUE - bitSizeI1 };
127
128                 inline Pair() {}
129                 inline Pair(Pair const &_p): i12(_p.i12) {}
130                 inline Pair(_T1 const &_i1, _T2 const &_i2):
131                         i12(((T12)_i1 << bitShiftI1) + (T12)_i2) {}
132
133                 template <typename __T1, typename __T2, typename __TCompression>
134                 inline Pair(Pair<__T1, __T2, __TCompression> const &_p):
135                         i12(((T12)getValueI1(_p) << bitShiftI1) + (T12)getValueI2(_p)) {}
136         }
137 #ifndef PLATFORM_WINDOWS
138         __attribute__((packed))
139 #endif
140         ;
141 #ifdef PLATFORM_WINDOWS
142     #pragma pack(pop)
143 #endif
144
145
146
147     template <typename _T1, typename _T2, typename TCompression>
148         std::ostream& operator<<(std::ostream &out, Pair<_T1,_T2,TCompression> const &p) {
149                 out << "< " << getValueI1(p) << " , " << getValueI2(p) << " >";
150                 return out;
151         }
152
153         template <typename T1, typename T2, typename TCompression>
154         struct Value< Pair<T1, T2, TCompression>, 1 > {
155                 typedef T1 Type;
156         };
157
158         template <typename T1, typename T2, typename TCompression>
159         struct Value< Pair<T1, T2, TCompression>, 2 > {
160                 typedef T2 Type;
161         };
162
163         template <typename T1, typename T2, typename TCompression>
164         struct Spec< Pair<T1, T2, TCompression> > {
165                 typedef TCompression Type;
166         };
167
168
169 //____________________________________________________________________________
170
171         template <typename TKey, typename TObject, typename TSpec>
172         struct Key< Pair<TKey, TObject, TSpec> > 
173         {
174                 typedef TKey Type;
175         };
176
177         template <typename TKey, typename TCargo, typename TSpec>
178         struct Cargo< Pair<TKey, TCargo, TSpec> > 
179         {
180                 typedef TCargo Type;
181         };
182 //____________________________________________________________________________
183
184 /**
185 .Class.Triple:
186 ..cat:Aggregates
187 ..summary:Stores three arbitrary objects.
188 ..signature:Triple<T1, T2, T3[, Compression]>
189 ..param.T1:The type of the first object.
190 ..param.T2:The type of the second object.
191 ..param.T3:The type of the third object.
192 ..param.Compression:If $Compressed$, the triple is stored in a more space efficient way (useful for external storage).
193 ...note:When compression is enabled, referring to members is not allowed.
194 ...default:$void$, no compression (faster access).
195 .Memfunc.Triple#Triple:
196 ..class:Class.Triple
197 ..summary:Constructor
198 ..signature:Triple<T1, T2, T3> ()
199 ..signature:Triple<T1, T2, T3> (triple)
200 ..signature:Triple<T1, T2, T3> (i1, i2, i3)
201 ..param.triple:Other Triple object. (copy constructor)
202 ..param.i1:T1 object.
203 ..param.i2:T2 object.
204 ..param.i3:T3 object.
205 .Memvar.Triple#i1:
206 ..class:Class.Triple
207 ..summary:T1 object
208 .Memvar.Triple#i2:
209 ..class:Class.Triple
210 ..summary:T2 object
211 .Memvar.Triple#i3:
212 ..class:Class.Triple
213 ..summary:T3 object
214 */
215
216         // standard storage 
217         template <typename _T1, typename _T2 = _T1, typename _T3 = _T1, typename TCompression = void>
218     struct Triple {
219         typedef _T1 T1;
220         typedef _T2 T2;
221         typedef _T3 T3;
222         _T1 i1;
223         _T2 i2;
224         _T3 i3;
225                 inline Triple() {}
226                 inline Triple(Triple const &_p):
227                         i1(_p.i1), i2(_p.i2), i3(_p.i3) {}
228                 inline Triple(_T1 const &_i1, _T2 const &_i2, _T3 const &_i3):
229                         i1(_i1), i2(_i2), i3(_i3) {}
230
231                 template <typename __T1, typename __T2, typename __T3, typename __TCompression>
232                 inline Triple(Triple<__T1, __T2, __T3, __TCompression> const &_p):
233                         i1(getValueI1(_p)), i2(getValueI2(_p)), i3(getValueI3(_p)) {}
234         };
235
236         // unaligned and unpadded storage (space efficient)
237 #ifdef PLATFORM_WINDOWS
238     #pragma pack(push,1)
239 #endif
240     template <typename _T1, typename _T2, typename _T3>
241     struct Triple<_T1, _T2, _T3, Compressed> {
242         typedef _T1 T1;
243         typedef _T2 T2;
244         typedef _T3 T3;
245         _T1 i1;
246         _T2 i2;
247         _T3 i3;
248                 inline Triple() {}
249                 inline Triple(Triple const &_p):
250                         i1(_p.i1), i2(_p.i2), i3(_p.i3) {}
251                 inline Triple(_T1 const &_i1, _T2 const &_i2, _T3 const &_i3):
252                         i1(_i1), i2(_i2), i3(_i3) {}
253
254                 template <typename __T1, typename __T2, typename __T3, typename __TCompression>
255                 inline Triple(Triple<__T1, __T2, __T3, __TCompression> const &_p):
256                         i1(getValueI1(_p)), i2(getValueI2(_p)), i3(getValueI3(_p)) {}
257         }
258 #ifndef PLATFORM_WINDOWS
259         __attribute__((packed))
260 #endif
261         ;
262 #ifdef PLATFORM_WINDOWS
263     #pragma pack(pop)
264 #endif
265
266         template <typename _T1, typename _T2, typename _T3, typename TCompression>
267         std::ostream& operator<<(std::ostream &out, Triple<_T1,_T2,_T3,TCompression> const &t) {
268                 out << "< " << getValueI1(t) << " , " << getValueI2(t) << " , " << getValueI3(t) << " >";
269                 return out;
270         }
271
272         template <typename T1, typename T2, typename T3, typename TCompression>
273         struct Value< Triple<T1, T2, T3, TCompression>, 1 > {
274                 typedef T1 Type;
275         };
276
277         template <typename T1, typename T2, typename T3, typename TCompression>
278         struct Value< Triple<T1, T2, T3, TCompression>, 2 > {
279                 typedef T2 Type;
280         };
281
282         template <typename T1, typename T2, typename T3, typename TCompression>
283         struct Value< Triple<T1, T2, T3, TCompression>, 3 > {
284                 typedef T3 Type;
285         };
286
287         template <typename T1, typename T2, typename T3, typename TCompression>
288         struct Spec< Triple<T1, T2, T3, TCompression> > {
289                 typedef TCompression Type;
290         };
291
292
293 //____________________________________________________________________________
294
295 /**
296 .Class.Tuple:
297 ..cat:Aggregates
298 ..summary:A plain fixed-length string.
299 ..signature:Tuple<T, size[, compress]>
300 ..param.T:The value type, that is the type of characters stored in the tuple.
301 ..param.size:The size/length of the tuple.
302 ...remarks:In contrast to @Class.String@ the length of Tuple is fixed.
303 ..param.compress:Enable/Disable compression.
304 ..param.compress:If $void$, no compression is used.
305 ..param.compress:If $Compressed$, the characters are stored as a bit sequence in an ordinal type (char, ..., __int64)
306 ...remarks:Only useful for small alphabets and small tuple sizes (|Sigma|^size <= 2^64) as for DNA or protein m-grams)
307 ...default:void.
308 ..see:Spec.Sampler
309 */
310
311         // standard storage 
312         template <typename _T, unsigned _size, typename TCompression = void>
313     struct Tuple {
314         typedef _T T;
315         enum { size = _size };
316         _T i[_size];
317
318                 template <typename TPos>
319         inline _T& operator[](TPos k) {
320             SEQAN_ASSERT(k >= 0 && k < size);
321             return i[k];
322         }
323                 template <typename TPos>
324         inline const _T& operator[](TPos k) const {
325             SEQAN_ASSERT(k >= 0 && k < size);
326             return i[k];
327         }
328                 inline _T* operator&() { return i; }
329                 inline const _T* operator&() const { return i; }
330
331                 // has to be inline because elements (like this tuple) of packed structs can't be arguments
332                 template <typename TPos, typename SSS>
333                 inline SSS const assignValueAt(TPos k, SSS const source) {
334                         return i[k] = source;
335                 }
336     };
337
338
339     template < unsigned char _size >
340         struct _BitVector {
341         typedef typename _BitVector<_size + 1>::Type Type;
342     };
343
344     template <> struct _BitVector<8> { typedef unsigned char Type; };
345     template <> struct _BitVector<16> { typedef unsigned short Type; };
346     template <> struct _BitVector<32> { typedef unsigned int Type; };
347     template <> struct _BitVector<64> { typedef __int64 Type; };
348     template <> struct _BitVector<255> { typedef __int64 Type; };
349
350         // bit-compressed storage (space efficient)
351 #ifdef PLATFORM_WINDOWS
352     #pragma pack(push,1)
353 #endif
354     template <typename _T, unsigned _size>
355     struct Tuple<_T, _size, Compressed> {
356         typedef _T T;
357         enum { size = _size };
358         enum { bitSize = BitsPerValue<_T>::VALUE };
359         enum { bitMask = (1 << bitSize) - 1 };
360         enum { mask = (1 << (size * bitSize)) - 1 };
361         typedef typename _BitVector< bitSize * size >::Type CT;
362         
363         CT i;
364 /*
365                 inline Tuple() {
366                         SEQAN_ASSERT(bitSize * size <= sizeof(CT) * 8);
367                 }
368 */
369                 template <typename TPos>
370         inline const _T operator[](TPos k) const {
371             SEQAN_ASSERT(k >= 0 && k < size);
372             return (i >> (size - 1 - k) * bitSize) & bitMask;
373         }
374                 template <unsigned __size>
375                 inline Tuple operator=(Tuple<_T, __size, Compressed> const &_right) {
376                         i = _right.i;
377                         return *this;
378                 }
379                 template <typename TShiftSize>
380         inline CT operator<<=(TShiftSize shift) {
381             return i = (i << (shift * bitSize)) & mask;
382         }
383                 template <typename TShiftSize>
384         inline CT operator<<(TShiftSize shift) const {
385             return (i << (shift * bitSize)) & mask;
386         }
387                 template <typename TShiftSize>
388         inline CT operator>>=(TShiftSize shift) {
389             return i = (i >> (shift * bitSize));
390         }
391                 template <typename TShiftSize>
392         inline CT operator>>(TShiftSize shift) const {
393             return i >> (shift * bitSize);
394         }
395         template <typename T>
396         inline void operator|=(T const &t) {
397             i |= t;
398         }
399         template <typename T, typename TSpec>
400         inline void operator|=(SimpleType<T, TSpec> const &t) {
401             i |= t.value;
402         }
403                 inline CT* operator&() { return &i; }
404                 inline const CT* operator&() const { return &i; }
405
406                 // has to be inline because elements (like this tuple) of packed structs can't be arguments
407                 template <typename TPos, typename SSS>
408                 inline SSS const assignValueAt(TPos k, SSS const source) {
409                         typedef Tuple<_T, _size, Compressed> Tup;
410                         typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * bitSize);
411                         i = (i & ~mask) | ((CT)source << ((_size - 1 - k) * bitSize));
412                         return source;
413                 }
414     }
415 #ifndef PLATFORM_WINDOWS
416         __attribute__((packed))
417 #endif
418         ;
419 #ifdef PLATFORM_WINDOWS
420     #pragma pack(pop)
421 #endif
422
423
424 //////////////////////////////////////////////////////////////////////////////
425 // length
426
427     template <typename _T, unsigned _size, typename TCompression>
428         inline unsigned length(Tuple<_T, _size, TCompression> const &) { return _size; }
429
430         ///.Metafunction.LENGTH.param.T.type:Class.Tuple
431     template <typename _T, unsigned _size, typename TCompression>
432         struct LENGTH< Tuple<_T, _size, TCompression> >
433         {
434                 enum { VALUE = _size };
435         };
436
437 //////////////////////////////////////////////////////////////////////////////
438 // assignValueAt
439
440     template <typename TObject, typename TPos, typename TSource>
441     inline TSource & 
442         assignValueAt(TObject &me, TPos k, TSource &source) {
443         assign(value(me, k), source);
444                 return source;
445     }
446
447     template <typename TObject, typename TPos, typename TSource>
448     inline TSource const & 
449         assignValueAt(TObject &me, TPos k, TSource const &source) {
450         assign(value(me, k), source);
451                 return source;
452     }
453
454     template <typename TTT, unsigned _size, typename SSS, typename TPos>
455     inline SSS const assignValueAt(Tuple<TTT, _size, void> &me, TPos k, SSS const source) {
456         return me.i[k] = source;
457     }
458
459     template <typename TTT, unsigned _size, typename SSS, typename TPos>
460     inline SSS const assignValueAt(Tuple<TTT, _size, Compressed> &me, TPos k, SSS const source) {
461         typedef Tuple<TTT, _size, Compressed> Tup;
462         typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * me.bitSize);
463         me.i = (me.i & ~mask) | source << ((_size - 1 - k) * me.bitSize);
464         return source;
465     }
466
467     template <typename TTT, typename SSS, typename SSSpec, unsigned _size, typename TPos>
468     inline SimpleType<SSS, SSSpec> const & assignValueAt(Tuple<TTT, _size, Compressed> &me, TPos k, SimpleType<SSS, SSSpec> const &source) {
469         typedef Tuple<TTT, _size, Compressed> Tup;
470         typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * me.bitSize);
471         me.i = (me.i & ~mask) | source.value << ((_size - 1 - k) * me.bitSize);
472         return source;
473     }
474
475 //////////////////////////////////////////////////////////////////////////////
476 // clear
477
478         template <typename TTT, unsigned _size, typename TCompression>
479         inline void clear(Tuple<TTT, _size, TCompression> &me) {
480         memset<sizeof(me.i), 0>(&(me.i));
481         }
482     template <typename TTT, unsigned _size>
483         inline void clear(Tuple<TTT, _size, Compressed> &me) {
484                 me.i = 0; 
485         }
486
487 //////////////////////////////////////////////////////////////////////////////
488 // optimized compares
489
490         template <typename TTT, unsigned _sizeL, unsigned _sizeR>
491         inline bool operator<(Tuple<TTT, _sizeL, Compressed> const &_left, Tuple<TTT, _sizeR, Compressed> const &_right) {
492                 return _left.i < _right.i;
493         }
494         template <typename TTT, unsigned _sizeL, unsigned _sizeR>
495         inline bool operator>(Tuple<TTT, _sizeL, Compressed> const &_left, Tuple<TTT, _sizeR, Compressed> const &_right) {
496                 return _left.i > _right.i;
497         }
498         template <typename TTT, unsigned _sizeL, unsigned _sizeR>
499         inline bool operator==(Tuple<TTT, _sizeL, Compressed> const &_left, Tuple<TTT, _sizeR, Compressed> const &_right) {
500                 return _left.i == _right.i;
501         }
502         template <typename TTT, unsigned _sizeL, unsigned _sizeR>
503         inline bool operator!=(Tuple<TTT, _sizeL, Compressed> const &_left, Tuple<TTT, _sizeR, Compressed> const &_right) {
504                 return _left.i != _right.i;
505         }
506
507 //////////////////////////////////////////////////////////////////////////////
508 // optimized shifts
509
510     struct _TupleShiftLeftWorker {
511         template <typename Arg>
512         static inline void body(Arg &arg, unsigned I) {
513             arg[I-1] = arg[I];
514         }
515     };
516
517     struct _TupleShiftRightWorker {
518         template <typename Arg>
519         static inline void body(Arg &arg, unsigned I) {
520             arg[I] = arg[I-1];
521         }
522     };
523
524         template <typename _T, unsigned _size, typename TCompression>
525         inline void shiftLeft(Tuple<_T, _size, TCompression> &me) {
526                 LOOP<_TupleShiftLeftWorker, _size - 1>::run(me);
527         }
528
529         template <typename _T, unsigned _size, typename TCompression>
530         inline void shiftRight(Tuple<_T, _size, TCompression> &me) {
531                 LOOP_REVERSE<_TupleShiftRightWorker, _size - 1>::run(me);
532         }
533
534         template <typename _T, unsigned _size>
535         inline void shiftLeft(Tuple<_T, _size, Compressed> &me) {
536                 me<<=1;
537         }
538
539         template <typename _T, unsigned _size>
540         inline void shiftRight(Tuple<_T, _size, Compressed> &me) {
541                 me>>=1;
542         }
543
544 //////////////////////////////////////////////////////////////////////////////
545 // standard output
546
547         template <typename _T, unsigned _size, typename TCompression>
548         std::ostream& operator<<(std::ostream& out, Tuple<_T,_size,TCompression> const &a) {
549                 out << "[";
550                 if (a.size > 0)
551                         out << a[0];
552                 for(unsigned j = 1; j < a.size; ++j)
553                         out << " " << a[j];
554                 out << "]";
555                 return out;
556         }
557
558         template <typename _T, unsigned _size, typename TCompression>
559         struct Value< Tuple<_T, _size, TCompression> > {
560                 typedef _T Type;
561         };
562
563         template <typename _T, unsigned _size, typename TCompression>
564         struct Spec< Tuple<_T, _size, TCompression> > {
565                 typedef TCompression Type;
566         };
567
568 //////////////////////////////////////////////////////////////////////////////
569 // getValueIx
570
571         template <typename T1, typename T2, typename TCompression>
572         inline T1 getValueI1(Pair<T1, T2, TCompression> const &pair) {
573                 return pair.i1;
574         }
575
576         template <typename T1, typename T2, typename TCompression>
577         inline T2 getValueI2(Pair<T1, T2, TCompression> const &pair) {
578                 return pair.i2;
579         }
580
581         template <typename T1, typename T2, unsigned valueSizeI1>
582         inline T1 getValueI1(Pair<T1, T2, CutCompressed<valueSizeI1> > const &pair) {
583                 typedef Pair<T1, T2, CutCompressed<valueSizeI1> > TPair;
584                 return pair.i12 >> TPair::bitShiftI1;
585         }
586
587         template <typename T1, typename T2, unsigned valueSizeI1>
588         inline T2 getValueI2(Pair<T1, T2, CutCompressed<valueSizeI1> > const &pair) {
589                 typedef Pair<T1, T2, CutCompressed<valueSizeI1> > TPair;                 
590                 return pair.i12 & (((typename TPair::T12)1 << TPair::bitShiftI1) - 1);
591         }
592 //____________________________________________________________________________
593
594         template <typename T1, typename T2, typename T3, typename TCompression>
595         inline T1 getValueI1(Triple<T1, T2, T3, TCompression> const &triple) {
596                 return triple.i1;
597         }
598
599         template <typename T1, typename T2, typename T3, typename TCompression>
600         inline T2 getValueI2(Triple<T1, T2, T3, TCompression> const &triple) {
601                 return triple.i2;
602         }
603
604         template <typename T1, typename T2, typename T3, typename TCompression>
605         inline T3 getValueI3(Triple<T1, T2, T3, TCompression> const &triple) {
606                 return triple.i3;
607         }
608
609 //////////////////////////////////////////////////////////////////////////////
610 // assignValueIx
611
612         template <typename T1, typename T2, typename TCompression, typename T>
613         inline void assignValueI1(Pair<T1, T2, TCompression> &pair, T const &_i) {
614                 pair.i1 = _i;
615         }
616
617         template <typename T1, typename T2, typename TCompression, typename T>
618         inline void assignValueI2(Pair<T1, T2, TCompression> &pair, T const &_i) {
619                 pair.i2 = _i;
620         }
621
622         template <typename T1, typename T2, unsigned valueSizeI1, typename T>
623         inline void assignValueI1(Pair<T1, T2, CutCompressed<valueSizeI1> > &pair, T const &_i) 
624         {
625                 typedef Pair<T1, T2, CutCompressed<valueSizeI1> > TPair;
626                 pair.i12 = ((typename TPair::T12)_i << TPair::bitShiftI1) |
627                            (pair.i12 & (((typename TPair::T12)1 << TPair::bitShiftI1) - 1));
628         }
629
630         template <typename T1, typename T2, unsigned valueSizeI1, typename T>
631         inline void assignValueI2(Pair<T1, T2, CutCompressed<valueSizeI1> > &pair, T const &_i) {
632                 typedef Pair<T1, T2, CutCompressed<valueSizeI1> > TPair;
633                 pair.i12 = (pair.i12 & ~(((typename TPair::T12)1 << TPair::bitShiftI1) - 1)) | _i;
634         }
635 //____________________________________________________________________________
636
637         template <typename T1, typename T2, typename T3, typename TCompression, typename T>
638         inline T const assignValueI1(Triple<T1, T2, T3, TCompression> &triple, T const &_i) {
639                 return triple.i1 = _i;
640         }
641
642         template <typename T1, typename T2, typename T3, typename TCompression, typename T>
643         inline T const assignValueI2(Triple<T1, T2, T3, TCompression> &triple, T const &_i) {
644                 return triple.i2 = _i;
645         }
646
647         template <typename T1, typename T2, typename T3, typename TCompression, typename T>
648         inline T const assignValueI3(Triple<T1, T2, T3, TCompression> &triple, T const &_i) {
649                 return triple.i3 = _i;
650         }
651
652 //////////////////////////////////////////////////////////////////////////////
653 // operator ==/!= for pairs and triples
654
655         template <typename L1, typename L2, typename LCompression, typename R1, typename R2, typename RCompression>
656         inline bool operator==(Pair<L1, L2, LCompression> const &_left, Pair<R1, R2, RCompression> const &_right) {
657                 return _left.i1 == _right.i1 && _left.i2 == _right.i2;
658         }
659         template <typename L1, typename L2, typename LCompression, typename R1, typename R2, typename RCompression>
660         inline bool operator!=(Pair<L1, L2, LCompression> const &_left, Pair<R1, R2, RCompression> const &_right) {
661                 return _left.i1 != _right.i1 || _left.i2 != _right.i2;
662         }
663
664         template <typename L1, typename L2, unsigned LSizeI1, typename R1, typename R2, unsigned RSizeI1>
665         inline bool operator==(Pair<L1, L2, CutCompressed<LSizeI1> > const &_left, Pair<R1, R2, CutCompressed<RSizeI1> > const &_right) {
666                 return _left.i12 == _right.i12;
667         }
668         template <typename L1, typename L2, unsigned LSizeI1, typename R1, typename R2, unsigned RSizeI1>
669         inline bool operator!=(Pair<L1, L2, CutCompressed<LSizeI1> > const &_left, Pair<R1, R2, CutCompressed<RSizeI1> > const &_right) {
670                 return _left.i12 != _right.i12;
671         }
672 //____________________________________________________________________________
673
674         template <
675                 typename L1, typename L2, typename L3, typename LCompression, 
676                 typename R1, typename R2, typename R3, typename RCompression>
677         inline bool operator==(Triple<L1, L2, L3, LCompression> const &_left, Triple<R1, R2, R3, RCompression> const &_right) {
678                 return _left.i1 == _right.i1 && _left.i2 == _right.i2 && _left.i3 == _right.i3;
679         }
680         template <
681                 typename L1, typename L2, typename L3, typename LCompression, 
682                 typename R1, typename R2, typename R3, typename RCompression>
683         inline bool operator!=(Triple<L1, L2, L3, LCompression> const &_left, Triple<R1, R2, R3, RCompression> const &_right) {
684                 return _left.i1 != _right.i1 || _left.i2 != _right.i2 || _left.i3 != _right.i3;
685         }
686
687 }// namespace SEQAN_NAMESPACE_MAIN
688
689 #endif //#ifndef SEQAN_HEADER_...