/usr/include/seqan/basic/basic_aggregates.h is in seqan-dev 1.3-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | // ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2010, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
#ifndef SEQAN_HEADER_BASIC_AGGREGATES_H
#define SEQAN_HEADER_BASIC_AGGREGATES_H
namespace SEQAN_NAMESPACE_MAIN
{
//____________________________________________________________________________
struct Compressed_;
typedef Tag<Compressed_> Compressed;
template <unsigned BITSIZE1 = 16, unsigned BITSIZE2 = 16>
struct BitCompressed;
/**
.Class.Pair:
..cat:Aggregates
..summary:Stores two arbitrary objects.
..signature:Pair<T1[, T2[, TSpec]]>
..param.T1:The type of the first object.
..param.T2:The type of the second object.
...default:$T1$
..param.TSpec:The specializing type.
...default:$void$, no compression (faster access).
.Memfunc.Pair#Pair:
..class:Class.Pair
..summary:Constructor
..signature:Pair<T1, T2[, TSpec]> ()
..signature:Pair<T1, T2[, TSpec]> (pair)
..signature:Pair<T1, T2[, TSpec]> (i1, i2)
..param.pair:Other Pair object. (copy constructor)
..param.i1:T1 object.
..param.i2:T2 object.
.Memvar.Pair#i1:
..class:Class.Pair
..summary:T1 object
.Memvar.Pair#i2:
..class:Class.Pair
..summary:T2 object
..include:seqan/basic.h
*/
// standard storage
template <typename T1_, typename T2_ = T1_, typename TSpec = void>
struct Pair {
typedef T1_ T1;
typedef T2_ T2;
T1_ i1;
T2_ i2;
inline Pair() {}
inline Pair(Pair const &_p): i1(_p.i1), i2(_p.i2) {}
inline Pair(T1_ const &_i1, T2_ const &_i2): i1(_i1), i2(_i2) {}
template <typename T1__, typename T2__, typename TSpec__>
inline Pair(Pair<T1__, T2__, TSpec__> const &_p):
i1(getValueI1(_p)), i2(getValueI2(_p)) {}
};
/**
.Spec.Packed Pair:
..cat:Aggregates
..general:Class.Pair
..summary:Stores two arbitrary objects. Saves memory by disabling memory alignment.
..signature:Pair<T1, T2, Compressed>
..param.T1:The type of the first object.
..param.T2:The type of the second object.
..notes:Useful for external storage.
..remarks:Memory access could be slower. Direct access to members by pointers is not allowed on all platforms.
..include:seqan/basic.h
.Memfunc.Pair#Pair.class:Spec.Packed Pair
.Memvar.Pair#i1.class:Spec.Packed Pair
.Memvar.Pair#i2.class:Spec.Packed Pair
*/
// unaligned and unpadded storage (space efficient)
#ifdef PLATFORM_WINDOWS
#pragma pack(push,1)
#endif
template <typename T1_, typename T2_>
struct Pair<T1_, T2_, Compressed> {
typedef T1_ T1;
typedef T2_ T2;
T1_ i1;
T2_ i2;
inline Pair() {}
inline Pair(Pair const &_p): i1(_p.i1), i2(_p.i2) {}
inline Pair(T1_ const &_i1, T2_ const &_i2): i1(_i1), i2(_i2) {}
template <typename T1__, typename T2__, typename TSpec__>
inline Pair(Pair<T1__, T2__, TSpec__> const &_p):
i1(getValueI1(_p)), i2(getValueI2(_p)) {}
}
#ifndef PLATFORM_WINDOWS
__attribute__((packed))
#endif
;
#ifdef PLATFORM_WINDOWS
#pragma pack(pop)
#endif
/**
.Spec.Bit Compressed Pair:
..cat:Aggregates
..general:Class.Pair
..summary:Stores two arbitrary objects. Saves memory by packing bits with bit fields.
..signature:Pair<T1, T2, BitCompressed<BITSIZE1, BITSIZE2> >
..param.T1:The type of the first object.
..param.T2:The type of the second object.
..param.BITSIZE1:Number of bits to store $T1$.
..param.BITSIZE2:Number of bits to store $T2$.
..notes:Useful for external storage.
..remarks:Memory access could be slower. Direct access to members by pointers is not allowed.
..include:seqan/basic.h
.Memfunc.Pair#Pair.class:Spec.Bit Compressed Pair
.Memvar.Pair#i1.class:Spec.Bit Compressed Pair
.Memvar.Pair#i2.class:Spec.Bit Compressed Pair
*/
template <typename T1_, typename T2_, unsigned BITSIZE1, unsigned BITSIZE2>
struct Pair<T1_, T2_, BitCompressed<BITSIZE1, BITSIZE2> > {
typedef T1_ T1;
typedef T2_ T2;
T1_ i1:BITSIZE1;
T2_ i2:BITSIZE2;
inline Pair() {}
inline Pair(Pair const &_p): i1(_p.i1), i2(_p.i2) {}
inline Pair(T1_ const &_i1, T2_ const &_i2): i1(_i1), i2(_i2) {}
template <typename T1__, typename T2__, typename TSpec__>
inline Pair(Pair<T1__, T2__, TSpec__> const &_p):
i1(getValueI1(_p)), i2(getValueI2(_p)) {}
};
template <typename T1_, typename T2_, typename TSpec>
std::ostream& operator<<(std::ostream &out, Pair<T1_,T2_,TSpec> const &p) {
out << "< " << getValueI1(p) << " , " << getValueI2(p) << " >";
return out;
}
template <typename T1, typename T2, typename TSpec>
struct Value< Pair<T1, T2, TSpec>, 1 > {
typedef T1 Type;
};
template <typename T1, typename T2, typename TSpec>
struct Value< Pair<T1, T2, TSpec>, 2 > {
typedef T2 Type;
};
template <typename T1, typename T2, typename TSpec>
struct Spec< Pair<T1, T2, TSpec> > {
typedef TSpec Type;
};
//____________________________________________________________________________
template <typename TKey, typename TObject, typename TSpec>
struct Key< Pair<TKey, TObject, TSpec> >
{
typedef TKey Type;
};
template <typename TKey, typename TCargo, typename TSpec>
struct Cargo< Pair<TKey, TCargo, TSpec> >
{
typedef TCargo Type;
};
//____________________________________________________________________________
/**
.Class.Triple:
..cat:Aggregates
..summary:Stores three arbitrary objects.
..signature:Triple<T1[, T2[, T3[, TSpec]]]>
..param.T1:The type of the first object.
..param.T2:The type of the second object.
...default:$T1$
..param.T3:The type of the third object.
...default:$T2$
..param.TSpec:The specializing type.
...default:$void$, no compression (faster access).
.Memfunc.Triple#Triple:
..class:Class.Triple
..summary:Constructor
..signature:Triple<T1, T2, T3[, TSpec]> ()
..signature:Triple<T1, T2, T3[, TSpec]> (triple)
..signature:Triple<T1, T2, T3[, TSpec]> (i1, i2, i3)
..param.triple:Other Triple object. (copy constructor)
..param.i1:T1 object.
..param.i2:T2 object.
..param.i3:T3 object.
.Memvar.Triple#i1:
..class:Class.Triple
..summary:T1 object
.Memvar.Triple#i2:
..class:Class.Triple
..summary:T2 object
.Memvar.Triple#i3:
..class:Class.Triple
..summary:T3 object
..include:seqan/basic.h
*/
// standard storage
template <typename T1_, typename T2_ = T1_, typename T3_ = T1_, typename TSpec = void>
struct Triple {
typedef T1_ T1;
typedef T2_ T2;
typedef T3_ T3;
T1_ i1;
T2_ i2;
T3_ i3;
inline Triple() {}
inline Triple(Triple const &_p):
i1(_p.i1), i2(_p.i2), i3(_p.i3) {}
inline Triple(T1_ const &_i1, T2_ const &_i2, T3_ const &_i3):
i1(_i1), i2(_i2), i3(_i3) {}
template <typename T1__, typename T2__, typename T3__, typename TSpec__>
inline Triple(Triple<T1__, T2__, T3__, TSpec__> const &_p):
i1(getValueI1(_p)), i2(getValueI2(_p)), i3(getValueI3(_p)) {}
inline bool
operator==(Triple const & other) const
{
return i1 == other.i1 && i2 == other.i2 && i3 == other.i3;
}
inline bool
operator<(Triple const & other) const
{
if (i1 < other.i1)
return true;
if (i1 == other.i1 && i2 < other.i2)
return true;
if (i1 == other.i1 && i2 == other.i2 && i3 < other.i3)
return true;
return false;
}
};
/**
.Spec.Packed Triple:
..cat:Aggregates
..general:Class.Triple
..summary:Stores three arbitrary objects. Saves memory by disabling memory alignment.
..signature:Triple<T1, T2, T3, Compressed>
..param.T1:The type of the first object.
..param.T2:The type of the second object.
..param.T3:The type of the third object.
..notes:Useful for external storage.
..remarks:Memory access could be slower. Direct access to members by pointers is not allowed on all platforms.
..include:seqan/basic.h
.Memfunc.Triple#Triple.class:Spec.Packed Triple
.Memvar.Triple#i1.class:Spec.Packed Triple
.Memvar.Triple#i2.class:Spec.Packed Triple
.Memvar.Triple#i3.class:Spec.Packed Triple
*/
// unaligned and unpadded storage (space efficient)
#ifdef PLATFORM_WINDOWS
#pragma pack(push,1)
#endif
template <typename T1_, typename T2_, typename T3_>
struct Triple<T1_, T2_, T3_, Compressed> {
typedef T1_ T1;
typedef T2_ T2;
typedef T3_ T3;
T1_ i1;
T2_ i2;
T3_ i3;
inline Triple() {}
inline Triple(Triple const &_p):
i1(_p.i1), i2(_p.i2), i3(_p.i3) {}
inline Triple(T1_ const &_i1, T2_ const &_i2, T3_ const &_i3):
i1(_i1), i2(_i2), i3(_i3) {}
template <typename T1__, typename T2__, typename T3__, typename TSpec__>
inline Triple(Triple<T1__, T2__, T3__, TSpec__> const &_p):
i1(getValueI1(_p)), i2(getValueI2(_p)), i3(getValueI3(_p)) {}
}
#ifndef PLATFORM_WINDOWS
__attribute__((packed))
#endif
;
#ifdef PLATFORM_WINDOWS
#pragma pack(pop)
#endif
template <typename T1_, typename T2_, typename T3_, typename TSpec>
std::ostream& operator<<(std::ostream &out, Triple<T1_,T2_,T3_,TSpec> const &t) {
out << "< " << getValueI1(t) << " , " << getValueI2(t) << " , " << getValueI3(t) << " >";
return out;
}
template <typename T1, typename T2, typename T3, typename TSpec>
struct Value< Triple<T1, T2, T3, TSpec>, 1 > {
typedef T1 Type;
};
template <typename T1, typename T2, typename T3, typename TSpec>
struct Value< Triple<T1, T2, T3, TSpec>, 2 > {
typedef T2 Type;
};
template <typename T1, typename T2, typename T3, typename TSpec>
struct Value< Triple<T1, T2, T3, TSpec>, 3 > {
typedef T3 Type;
};
template <typename T1, typename T2, typename T3, typename TSpec>
struct Spec< Triple<T1, T2, T3, TSpec> > {
typedef TSpec Type;
};
//____________________________________________________________________________
/**
.Class.Tuple:
..cat:Aggregates
..summary:A plain fixed-length string.
..signature:Tuple<T, SIZE[, TSpec]>
..param.T:The value type, that is the type of characters stored in the tuple.
..param.SIZE:The size/length of the tuple.
...remarks:In contrast to @Class.String@ the length of Tuple is fixed.
..param.TSpec:The specializing type.
...default:$void$, no compression (faster access).
..include:seqan/basic.h
*/
// standard storage
template <typename T_, unsigned _size, typename TSpec = void>
struct Tuple {
typedef T_ T;
enum { size = _size };
T_ i[_size];
template <typename TPos>
inline T_& operator[](TPos k) {
SEQAN_ASSERT_GEQ(static_cast<__int64>(k), 0);
SEQAN_ASSERT_LT(static_cast<__int64>(k), static_cast<__int64>(size));
return i[k];
}
template <typename TPos>
inline const T_& operator[](TPos k) const {
SEQAN_ASSERT_GEQ(static_cast<__int64>(k), 0);
SEQAN_ASSERT_LT(static_cast<__int64>(k), static_cast<__int64>(size));
return i[k];
}
inline T_* operator&() { return i; }
inline const T_* operator&() const { return i; }
// has to be inline because elements (like this tuple) of packed structs can't be arguments
template <typename TPos, typename tmpS>
inline tmpS const assignValueAt(TPos k, tmpS const source) {
return i[k] = source;
}
};
template < unsigned char _size >
struct BitVector_ {
typedef typename BitVector_<_size + 1>::Type Type;
};
template <> struct BitVector_<8> { typedef unsigned char Type; };
template <> struct BitVector_<16> { typedef unsigned short Type; };
template <> struct BitVector_<32> { typedef unsigned long Type; };
template <> struct BitVector_<64> { typedef __uint64 Type; };
template <> struct BitVector_<255> { typedef __uint64 Type; };
/**
.Spec.Bit Packed Tuple:
..cat:Aggregates
..general:Class.Tuple
..summary:A plain fixed-length string. Saves memory by packing bits.
..signature:Tuple<T, SIZE, Compressed>
..param.T:The value type, that is the type of characters stored in the tuple.
..param.SIZE:The size/length of the tuple.
...remarks:In contrast to @Class.String@ the length of Tuple is fixed.
..notes:The characters are stored as a bit sequence in an ordinal type (char, ..., __int64).
..remarks:Only useful for small alphabets and small tuple sizes (|Sigma|^size <= 2^64) as for @Spec.Dna@ or @Spec.AminoAcid@ m-grams)
..see:Spec.Sampler
..include:seqan/basic.h
*/
// bit-compressed storage (space efficient)
#ifdef PLATFORM_WINDOWS
#pragma pack(push,1)
#endif
template <typename T_, unsigned _size>
struct Tuple<T_, _size, Compressed> {
typedef T_ T;
enum { size = _size };
enum { bitSize = BitsPerValue<T_>::VALUE };
enum { bitMask = (1 << bitSize) - 1 };
enum { mask = (1 << (size * bitSize)) - 1 };
typedef typename BitVector_< bitSize * size >::Type CT;
CT i;
/*
inline Tuple() {
SEQAN_ASSERT(bitSize * size <= sizeof(CT) * 8);
}
*/
template <typename TPos>
inline const T_ operator[](TPos k) const {
SEQAN_ASSERT_GEQ(static_cast<__int64>(k), 0);
SEQAN_ASSERT_LT(static_cast<__int64>(k), static_cast<__int64>(size));
return (i >> (size - 1 - k) * bitSize) & bitMask;
}
template <unsigned size__>
inline Tuple operator=(Tuple<T_, size__, Compressed> const &_right) {
i = _right.i;
return *this;
}
template <typename TShiftSize>
inline CT operator<<=(TShiftSize shift) {
return i = (i << (shift * bitSize)) & mask;
}
template <typename TShiftSize>
inline CT operator<<(TShiftSize shift) const {
return (i << (shift * bitSize)) & mask;
}
template <typename TShiftSize>
inline CT operator>>=(TShiftSize shift) {
return i = (i >> (shift * bitSize));
}
template <typename TShiftSize>
inline CT operator>>(TShiftSize shift) const {
return i >> (shift * bitSize);
}
template <typename T>
inline void operator|=(T const &t) {
i |= t;
}
template <typename T, typename TSpec>
inline void operator|=(SimpleType<T, TSpec> const &t) {
i |= t.value;
}
inline CT* operator&() { return &i; }
inline const CT* operator&() const { return &i; }
// has to be inline because elements (like this tuple) of packed structs can't be arguments
template <typename TPos, typename tmpS>
inline tmpS const assignValueAt(TPos k, tmpS const source) {
typedef Tuple<T_, _size, Compressed> Tup;
typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * bitSize);
i = (i & ~mask) | ((CT)ordValue(source) << ((_size - 1 - k) * bitSize));
return source;
}
}
#ifndef PLATFORM_WINDOWS
__attribute__((packed))
#endif
;
#ifdef PLATFORM_WINDOWS
#pragma pack(pop)
#endif
//////////////////////////////////////////////////////////////////////////////
// length
template <typename T_, unsigned _size, typename TSpec>
inline unsigned length(Tuple<T_, _size, TSpec> const &) { return _size; }
///.Metafunction.LENGTH.param.T.type:Class.Tuple
template <typename T_, unsigned _size, typename TSpec>
struct LENGTH< Tuple<T_, _size, TSpec> >
{
enum { VALUE = _size };
};
//////////////////////////////////////////////////////////////////////////////
// assignValueAt
template <typename TObject, typename TPos, typename TSource>
inline TSource &
assignValueAt(TObject &me, TPos k, TSource &source) {
assign(value(me, k), source);
return source;
}
template <typename TObject, typename TPos, typename TSource>
inline TSource const &
assignValueAt(TObject &me, TPos k, TSource const &source) {
assign(value(me, k), source);
return source;
}
template <typename T_, unsigned _size, typename tmpS, typename TPos>
inline tmpS const assignValueAt(Tuple<T_, _size, void> &me, TPos k, tmpS const source) {
return me.i[k] = source;
}
template <typename T_, unsigned _size, typename tmpS, typename TPos>
inline tmpS const assignValueAt(Tuple<T_, _size, Compressed> &me, TPos k, tmpS const source) {
typedef Tuple<T_, _size, Compressed> Tup;
typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * me.bitSize);
me.i = (me.i & ~mask) | source << ((_size - 1 - k) * me.bitSize);
return source;
}
template <typename T_, typename tmpS, typename Spec_, unsigned _size, typename TPos>
inline SimpleType<tmpS, Spec_> const & assignValueAt(Tuple<T_, _size, Compressed> &me, TPos k, SimpleType<tmpS, Spec_> const &source) {
typedef Tuple<T_, _size, Compressed> Tup;
typename Tup::CT mask = Tup::bitMask << ((_size - 1 - k) * me.bitSize);
me.i = (me.i & ~mask) | source.value << ((_size - 1 - k) * me.bitSize);
return source;
}
//////////////////////////////////////////////////////////////////////////////
// clear
template <typename T_, unsigned _size, typename TSpec>
inline void clear(Tuple<T_, _size, TSpec> &me) {
memset<sizeof(me.i), 0>(&(me.i));
}
template <typename T_, unsigned _size>
inline void clear(Tuple<T_, _size, Compressed> &me) {
me.i = 0;
}
//////////////////////////////////////////////////////////////////////////////
// optimized compares
template <typename T_, unsigned _sizeL, unsigned _sizeR>
inline bool operator<(Tuple<T_, _sizeL, Compressed> const &_left, Tuple<T_, _sizeR, Compressed> const &_right) {
return _left.i < _right.i;
}
template <typename T_, unsigned _sizeL, unsigned _sizeR>
inline bool operator>(Tuple<T_, _sizeL, Compressed> const &_left, Tuple<T_, _sizeR, Compressed> const &_right) {
return _left.i > _right.i;
}
template <typename T_, unsigned _sizeL, unsigned _sizeR>
inline bool operator==(Tuple<T_, _sizeL, Compressed> const &_left, Tuple<T_, _sizeR, Compressed> const &_right) {
return _left.i == _right.i;
}
template <typename T_, unsigned _sizeL, unsigned _sizeR>
inline bool operator!=(Tuple<T_, _sizeL, Compressed> const &_left, Tuple<T_, _sizeR, Compressed> const &_right) {
return _left.i != _right.i;
}
//////////////////////////////////////////////////////////////////////////////
// optimized shifts
struct TupleShiftLeftWorker_ {
template <typename Arg>
static inline void body(Arg &arg, unsigned I) {
arg[I-1] = arg[I];
}
};
struct TupleShiftRightWorker_ {
template <typename Arg>
static inline void body(Arg &arg, unsigned I) {
arg[I] = arg[I-1];
}
};
template <typename T_, unsigned _size, typename TSpec>
inline void shiftLeft(Tuple<T_, _size, TSpec> &me) {
Loop<TupleShiftLeftWorker_, _size - 1>::run(me);
}
template <typename T_, unsigned _size, typename TSpec>
inline void shiftRight(Tuple<T_, _size, TSpec> &me) {
LoopReverse<TupleShiftRightWorker_, _size - 1>::run(me);
}
template <typename T_, unsigned _size>
inline void shiftLeft(Tuple<T_, _size, Compressed> &me) {
me<<=1;
}
template <typename T_, unsigned _size>
inline void shiftRight(Tuple<T_, _size, Compressed> &me) {
me>>=1;
}
//////////////////////////////////////////////////////////////////////////////
// standard output
template <typename T_, unsigned _size, typename TSpec>
std::ostream& operator<<(std::ostream& out, Tuple<T_,_size,TSpec> const &a) {
out << "[";
if (a.size > 0)
out << a[0];
for(unsigned j = 1; j < a.size; ++j)
out << " " << a[j];
out << "]";
return out;
}
template <typename T_, unsigned _size, typename TSpec>
struct Value< Tuple<T_, _size, TSpec> > {
typedef T_ Type;
};
template <typename T_, unsigned _size, typename TSpec>
struct Spec< Tuple<T_, _size, TSpec> > {
typedef TSpec Type;
};
//////////////////////////////////////////////////////////////////////////////
// getValueIx
template <typename T1, typename T2, typename TSpec>
inline T1 getValueI1(Pair<T1, T2, TSpec> const &pair) {
return pair.i1;
}
template <typename T1, typename T2, typename TSpec>
inline T2 getValueI2(Pair<T1, T2, TSpec> const &pair) {
return pair.i2;
}
//____________________________________________________________________________
template <typename T1, typename T2, typename T3, typename TSpec>
inline T1 getValueI1(Triple<T1, T2, T3, TSpec> const &triple) {
return triple.i1;
}
template <typename T1, typename T2, typename T3, typename TSpec>
inline T2 getValueI2(Triple<T1, T2, T3, TSpec> const &triple) {
return triple.i2;
}
template <typename T1, typename T2, typename T3, typename TSpec>
inline T3 getValueI3(Triple<T1, T2, T3, TSpec> const &triple) {
return triple.i3;
}
//////////////////////////////////////////////////////////////////////////////
// assignValueIx
template <typename T1, typename T2, typename TSpec, typename T>
inline void assignValueI1(Pair<T1, T2, TSpec> &pair, T const &_i) {
pair.i1 = _i;
}
template <typename T1, typename T2, typename TSpec, typename T>
inline void assignValueI2(Pair<T1, T2, TSpec> &pair, T const &_i) {
pair.i2 = _i;
}
//____________________________________________________________________________
template <typename T1, typename T2, typename T3, typename TSpec, typename T>
inline T const assignValueI1(Triple<T1, T2, T3, TSpec> &triple, T const &_i) {
return triple.i1 = _i;
}
template <typename T1, typename T2, typename T3, typename TSpec, typename T>
inline T const assignValueI2(Triple<T1, T2, T3, TSpec> &triple, T const &_i) {
return triple.i2 = _i;
}
template <typename T1, typename T2, typename T3, typename TSpec, typename T>
inline T const assignValueI3(Triple<T1, T2, T3, TSpec> &triple, T const &_i) {
return triple.i3 = _i;
}
//////////////////////////////////////////////////////////////////////////////
// operator ==/!= for pairs and triples
template <typename L1, typename L2, typename LCompression, typename R1, typename R2, typename RCompression>
inline bool operator==(Pair<L1, L2, LCompression> const &_left, Pair<R1, R2, RCompression> const &_right) {
return _left.i1 == _right.i1 && _left.i2 == _right.i2;
}
template <typename L1, typename L2, typename LCompression, typename R1, typename R2, typename RCompression>
inline bool operator!=(Pair<L1, L2, LCompression> const &_left, Pair<R1, R2, RCompression> const &_right) {
return _left.i1 != _right.i1 || _left.i2 != _right.i2;
}
//____________________________________________________________________________
template <
typename L1, typename L2, typename L3, typename LCompression,
typename R1, typename R2, typename R3, typename RCompression>
inline bool operator==(Triple<L1, L2, L3, LCompression> const &_left, Triple<R1, R2, R3, RCompression> const &_right) {
return _left.i1 == _right.i1 && _left.i2 == _right.i2 && _left.i3 == _right.i3;
}
template <
typename L1, typename L2, typename L3, typename LCompression,
typename R1, typename R2, typename R3, typename RCompression>
inline bool operator!=(Triple<L1, L2, L3, LCompression> const &_left, Triple<R1, R2, R3, RCompression> const &_right) {
return _left.i1 != _right.i1 || _left.i2 != _right.i2 || _left.i3 != _right.i3;
}
}// namespace SEQAN_NAMESPACE_MAIN
#endif //#ifndef SEQAN_HEADER_...
|