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
|
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2013 NVIDIA Corporation
// 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 NVIDIA Corporation 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 NVIDIA CORPORATION 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.
//
// ==========================================================================
// Author: David Weese <david.weese@fu-berlin.de>
// Author: Enrico Siragusa <enrico.siragusa@fu-berlin.de>
// ==========================================================================
#ifndef SEQAN_SEQUENCE_CONTAINER_VIEW_H
#define SEQAN_SEQUENCE_CONTAINER_VIEW_H
namespace seqan {
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ----------------------------------------------------------------------------
// Tag Resizable
// ----------------------------------------------------------------------------
template <typename TSpec = void>
struct Resizable;
// ----------------------------------------------------------------------------
// Class ContainerView
// ----------------------------------------------------------------------------
/*!
* @class ContainerView
* @implements ContainerConcept
* @headerfile <seqan/sequence.h>
*
* @brief Generates a non-resizable view over a container.
*
* @signature template <TContainer, typename TSpec>
* class ContainerView<TContainer, TSpec>
*
* @tparam TContainer The container type to create the view for.
* @tparam TSpec The specialization type. Defaults to void.
*
* A @link ContainerView @endlink is a lightweight data structure storing only a begin and end
* pointer to an underlying container. The view can represent any range between the
* global begin and end of the contaniner. The view itself implements the @link ContainerConcept @endlink.
* The default implementation however is not resizable. The @link ResizableContainerView @endlink supports
* resizing of the view, but must not change the capacity of the underlying container.
*/
template <typename TContainer, typename TSpec = void>
class ContainerView
{
public:
typedef typename Iterator<ContainerView, Standard>::Type TIterator;
TIterator _begin;
TIterator _end;
// ------------------------------------------------------------------------
// ContainerView Constructors
// ------------------------------------------------------------------------
/*!
* @fn ContainerView#ContainerView
* @brief The constructor.
*
* @signature ContainerView();
* ContainerView(TOtherContainer & cont);
* ContainerView(TOtherContainer const & cont);
* ContainerView(TIterator const & begin, TIterator const & end);
*
* @param cont Another container to copy from.
* @param begin An iterator pointing to the beginning of the view.
* @param end An iterator pointing to the end of the view.
*/
inline
ContainerView() :
_begin(),
_end()
{}
template <typename TOtherContainer>
inline
ContainerView(TOtherContainer & cont):
_begin(begin(cont, Standard())),
_end(end(cont, Standard()))
{}
template <typename TOtherContainer>
inline
ContainerView(TOtherContainer const & cont):
_begin(begin(cont, Standard())),
_end(end(cont, Standard()))
{}
inline
ContainerView(TIterator const & begin, TIterator const & end):
_begin(begin),
_end(end)
{}
// ------------------------------------------------------------------------
// Operator =
// ------------------------------------------------------------------------
template <typename TOtherContainer>
inline
ContainerView &
operator= (TOtherContainer & other)
{
assign(*this, other);
return *this;
}
// ------------------------------------------------------------------------
// Operator []
// ------------------------------------------------------------------------
template <typename TPos>
inline
typename Reference<ContainerView>::Type
operator[] (TPos pos)
{
return value(*this, pos);
}
template <typename TPos>
inline
typename GetValue<ContainerView>::Type
operator[] (TPos pos) const
{
return getValue(*this, pos);
}
};
// ----------------------------------------------------------------------------
// Class Resizable ContainerView
// ----------------------------------------------------------------------------
/*!
* @class ResizableContainerView
* @extends ContainerView
* @headerfile <seqan/sequence.h>
*
* @brief Generates a resizable view over a container.
*
* @signature template <TContainer, typename TSpec>
* class ContainerView<TContainer, Resizable<TSpec> >
*
* @tparam TContainer The container type to create the view for.
* @tparam TSpec The specialization type.
*/
template <typename TContainer, typename TSpec>
class ContainerView<TContainer, Resizable<TSpec> > :
public ContainerView<TContainer, TSpec>
{
public:
typedef ContainerView<TContainer, TSpec> TBase;
typedef typename TBase::TIterator TIterator;
typedef typename Size<TContainer>::Type TSize;
TSize _capacity;
// ------------------------------------------------------------------------
// ContainerView Constructors
// ------------------------------------------------------------------------
inline
ContainerView() :
TBase(),
_capacity(0)
{}
template <typename TOtherContainer>
inline
ContainerView(TOtherContainer & cont) :
TBase(cont),
_capacity(capacity(cont))
{}
template <typename TOtherContainer>
inline
ContainerView(TOtherContainer const & cont) :
TBase(cont),
_capacity(capacity(cont))
{}
inline
ContainerView(TIterator const & begin, TIterator const & end) :
TBase(begin, end),
_capacity(end - begin)
{}
};
// ============================================================================
// Metafunctions
// ============================================================================
// ----------------------------------------------------------------------------
// Concept ContainerConcept
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
SEQAN_CONCEPT_IMPL((ContainerView<TContainer, TSpec>), (ContainerConcept));
template <typename TContainer, typename TSpec>
SEQAN_CONCEPT_IMPL((ContainerView<TContainer, TSpec> const), (ContainerConcept));
// ----------------------------------------------------------------------------
// Metafunction View
// ----------------------------------------------------------------------------
template <typename TValue, typename TAlloc>
struct View<String<TValue, TAlloc> >
{
typedef ContainerView<String<TValue, TAlloc> > Type;
};
// ----------------------------------------------------------------------------
// Metafunction RemoveView
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct RemoveView<ContainerView<TContainer, TSpec> >
{
typedef TContainer Type;
};
// ----------------------------------------------------------------------------
// Metafunction IsView
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct IsView<ContainerView<TContainer, TSpec> > : True {};
// ----------------------------------------------------------------------------
// Metafunction Value
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Value<ContainerView<TContainer, TSpec> >
{
typedef typename Value<TContainer>::Type Type;
};
template <typename TContainer, typename TSpec>
struct Value<ContainerView<TContainer, TSpec> const> :
public Value<ContainerView<TContainer const, TSpec> > {};
// ----------------------------------------------------------------------------
// Metafunction GetValue
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct GetValue<ContainerView<TContainer, TSpec> >
{
typedef ContainerView<TContainer, TSpec> TContainerView_;
typedef typename Iterator<TContainerView_, Standard>::Type TIterator_;
typedef typename GetValue<TIterator_>::Type Type;
};
template <typename TContainer, typename TSpec>
struct GetValue<ContainerView<TContainer, TSpec> const>
{
typedef ContainerView<TContainer, TSpec> const TContainerView_;
typedef typename Iterator<TContainerView_, Standard>::Type TIterator_;
typedef typename GetValue<TIterator_>::Type Type;
};
// ----------------------------------------------------------------------------
// Metafunction Iterator
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Iterator<ContainerView<TContainer, TSpec>, Standard>:
public Iterator<TContainer, Standard> {};
template <typename TContainer, typename TSpec>
struct Iterator<ContainerView<TContainer, TSpec> const, Standard>:
public Iterator<TContainer const, Standard> {};
// ----------------------------------------------------------------------------
// Metafunction Difference
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Difference<ContainerView<TContainer, TSpec> >
{
typedef typename Difference<TContainer>::Type Type;
};
// ----------------------------------------------------------------------------
// Metafunction Size
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Size<ContainerView<TContainer, TSpec> >
{
typedef typename Size<TContainer>::Type Type;
};
// ----------------------------------------------------------------------------
// Metafunction Position
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Position<ContainerView<TContainer, TSpec> >
{
typedef typename Position<TContainer>::Type Type;
};
// ----------------------------------------------------------------------------
// Metafunction IsSequence
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct IsSequence<ContainerView<TContainer, TSpec> >:
public IsSequence<TContainer> {};
// ----------------------------------------------------------------------------
// Metafunction Prefix
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Prefix<ContainerView<TContainer, TSpec> >
{
typedef ContainerView<TContainer, TSpec> Type;
};
template <typename TContainer, typename TSpec>
struct Prefix<ContainerView<TContainer, TSpec> const> :
Prefix<ContainerView<TContainer, TSpec> > {};
// ----------------------------------------------------------------------------
// Metafunction Suffix
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Suffix<ContainerView<TContainer, TSpec> >
{
typedef ContainerView<TContainer, TSpec> Type;
};
template <typename TContainer, typename TSpec>
struct Suffix<ContainerView<TContainer, TSpec> const> :
Suffix<ContainerView<TContainer, TSpec> > {};
// ----------------------------------------------------------------------------
// Metafunction Infix
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
struct Infix<ContainerView<TContainer, TSpec> >
{
typedef ContainerView<TContainer, TSpec> Type;
};
template <typename TContainer, typename TSpec>
struct Infix<ContainerView<TContainer, TSpec> const> :
Infix<ContainerView<TContainer, TSpec> > {};
// ----------------------------------------------------------------------------
// Metafunction View
// ----------------------------------------------------------------------------
template <typename THost, typename TSpec>
struct View<Segment<THost, TSpec> >
{
typedef typename View<THost>::Type Type;
};
// ============================================================================
// Functions
// ============================================================================
// ----------------------------------------------------------------------------
// Function begin()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
inline
typename Iterator<ContainerView<TContainer, TSpec>, Standard>::Type
begin(ContainerView<TContainer, TSpec> & view, Standard)
{
return view._begin;
}
template <typename TContainer, typename TSpec>
inline
typename Iterator<ContainerView<TContainer, TSpec> const, Standard>::Type
begin(ContainerView<TContainer, TSpec> const & view, Standard)
{
return view._begin;
}
// ----------------------------------------------------------------------------
// Function end()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
inline
typename Iterator<ContainerView<TContainer, TSpec>, Standard>::Type
end(ContainerView<TContainer, TSpec> & view, Standard)
{
return view._end;
}
template <typename TContainer, typename TSpec>
inline
typename Iterator<ContainerView<TContainer, TSpec> const, Standard>::Type
end(ContainerView<TContainer, TSpec> const & view, Standard)
{
return view._end;
}
// ----------------------------------------------------------------------------
// Function value()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TPos>
inline
typename Reference<ContainerView<TContainer, TSpec> >::Type
value(ContainerView<TContainer, TSpec> & view, TPos pos)
{
SEQAN_ASSERT_LT_MSG(pos, static_cast<TPos>(length(view)), "Trying to acces an element behind the last one!");
return *(view._begin + pos);
}
template <typename TContainer, typename TSpec, typename TPos>
inline
typename Reference<ContainerView<TContainer, TSpec> const>::Type
value(ContainerView<TContainer, TSpec> const & view, TPos pos)
{
SEQAN_ASSERT_LT_MSG(pos, static_cast<TPos>(length(view)), "Trying to acces an element behind the last one!");
return *(view._begin + pos);
}
// ----------------------------------------------------------------------------
// Function getValue()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TPos>
inline
typename GetValue<ContainerView<TContainer, TSpec> >::Type
getValue(ContainerView<TContainer, TSpec> & view, TPos pos)
{
SEQAN_ASSERT_LT_MSG(pos, static_cast<TPos>(length(view)), "Trying to acces an element behind the last one!");
return getValue(view._begin + pos);
}
template <typename TContainer, typename TSpec, typename TPos>
inline
typename GetValue<ContainerView<TContainer, TSpec> const>::Type
getValue(ContainerView<TContainer, TSpec> const & view, TPos pos)
{
SEQAN_ASSERT_LT_MSG(pos, static_cast<TPos>(length(view)), "Trying to acces an element behind the last one!");
return getValue(view._begin + pos);
}
// ----------------------------------------------------------------------------
// Function length()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
inline
typename Size<ContainerView<TContainer, TSpec> >::Type
length(ContainerView<TContainer, TSpec> const & view)
{
return view._end - view._begin;
}
// ----------------------------------------------------------------------------
// Function resize()
// ----------------------------------------------------------------------------
// this function doesn't do anything as we are not allowed to change the host (only its elements)
// it is, however, implemented for algorithms that get a sequence to work on
// and need to make sure that it has a certain length
template <typename TContainer, typename TSpec, typename TSize, typename TValue, typename TExpand>
inline typename Size< ContainerView<TContainer, TSpec> >::Type
resize(ContainerView<TContainer, TSpec> & me, TSize new_length, TValue /* val */, Tag<TExpand>)
{
ignoreUnusedVariableWarning(new_length);
SEQAN_ASSERT_EQ(new_length, (TSize)length(me));
return length(me);
}
template <typename TContainer, typename TSpec, typename TSize, typename TExpand>
inline typename Size< ContainerView<TContainer, TSpec> >::Type
resize(ContainerView<TContainer, TSpec> & me, TSize new_length, Tag<TExpand> tag)
{
return resize(me, new_length, Nothing(), tag);
}
// ----------------------------------------------------------------------------
// Function resize(); Resizable ContainerView
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TSize, typename TValue, typename TExpand>
inline typename Size< ContainerView<TContainer, Resizable<TSpec> > >::Type
resize(ContainerView<TContainer, Resizable<TSpec> > & me, TSize new_length, TValue /* val */, Tag<TExpand>)
{
SEQAN_ASSERT_LEQ(new_length, (TSize)capacity(me));
me._end = me._begin + new_length;
return length(me);
}
template <typename TContainer, typename TSpec, typename TSize, typename TExpand>
inline typename Size< ContainerView<TContainer, Resizable<TSpec> > >::Type
resize(ContainerView<TContainer, Resizable<TSpec> > & me, TSize new_length, Tag<TExpand> tag)
{
return resize(me, new_length, Nothing(), tag);
}
// NOTE(esiragusa): It is not necessary to overload it, but otherwise I had to qualify the generic one :(
template <typename TContainer, typename TSpec, typename TSize>
inline typename Size< ContainerView<TContainer, Resizable<TSpec> > >::Type
resize(ContainerView<TContainer, Resizable<TSpec> > & me, TSize new_length)
{
typedef ContainerView<TContainer, Resizable<TSpec> > TView;
return resize(me, new_length, Nothing(), typename DefaultOverflowImplicit<TView>::Type());
}
// ----------------------------------------------------------------------------
// Function prefix()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TPosEnd>
inline typename Prefix<ContainerView<TContainer, TSpec> const>::Type
prefix(ContainerView<TContainer, TSpec> const & view, TPosEnd pos_end)
{
return typename Prefix<ContainerView<TContainer, TSpec> const>::Type(view._begin, view._begin + pos_end);
}
template <typename TContainer, typename TSpec, typename TPosEnd>
inline typename Prefix<ContainerView<TContainer, TSpec> >::Type
prefix(ContainerView<TContainer, TSpec> & view, TPosEnd pos_end)
{
return prefix(reinterpret_cast<ContainerView<TContainer, TSpec> const &>(view), pos_end);
}
// ----------------------------------------------------------------------------
// Function suffix()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TPosBegin>
inline typename Suffix<ContainerView<TContainer, TSpec> const>::Type
suffix(ContainerView<TContainer, TSpec> const & view, TPosBegin pos_begin)
{
return typename Suffix<ContainerView<TContainer, TSpec> const>::Type(view._begin + pos_begin, view._end);
}
template <typename TContainer, typename TSpec, typename TPosBegin>
inline typename Suffix<ContainerView<TContainer, TSpec> >::Type
suffix(ContainerView<TContainer, TSpec> & view, TPosBegin pos_begin)
{
return suffix(reinterpret_cast<ContainerView<TContainer, TSpec> const &>(view), pos_begin);
}
// ----------------------------------------------------------------------------
// Function infix()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TPosBegin, typename TPosEnd>
inline typename Infix<ContainerView<TContainer, TSpec> const>::Type
infix(ContainerView<TContainer, TSpec> const & view, TPosBegin pos_begin, TPosEnd pos_end)
{
return typename Infix<ContainerView<TContainer, TSpec> >::Type(view._begin + pos_begin, view._begin + pos_end);
}
template <typename TContainer, typename TSpec, typename TPosBegin, typename TPosEnd>
inline typename Infix<ContainerView<TContainer, TSpec> >::Type
infix(ContainerView<TContainer, TSpec> & view, TPosBegin pos_begin, TPosEnd pos_end)
{
return infix(reinterpret_cast<ContainerView<TContainer, TSpec> const &>(view), pos_begin, pos_end);
}
// TODO(esiragusa): infix of view pointer?
//template <typename T, typename TPosBegin, typename TPosEnd>
//inline typename Infix<T *>::Type
//infix(T * t, TPosBegin pos_begin, TPosEnd pos_end)
//{
// return typename Infix<T *>::Type (t, pos_begin, pos_end);
//}
// ----------------------------------------------------------------------------
// Function assign()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TOtherContainer>
inline void assign(ContainerView<TContainer, TSpec> & view, TOtherContainer const & cont)
{
view._begin = begin(cont, Standard());
view._end = end(cont, Standard());
}
template <typename TContainer, typename TSpec, typename TOtherContainer>
inline void assign(ContainerView<TContainer, Resizable<TSpec> > & view, TOtherContainer const & cont)
{
view._begin = begin(cont, Standard());
view._end = end(cont, Standard());
view._capacity = capacity(cont, Standard());
}
// ----------------------------------------------------------------------------
// Function capacity()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
inline typename Size<ContainerView<TContainer, Resizable<TSpec> > >::Type
capacity(ContainerView<TContainer, Resizable<TSpec> > const & view)
{
return view._capacity;
}
// ----------------------------------------------------------------------------
// Function appendValue()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec, typename TValue, typename TExpand>
inline void
appendValue(ContainerView<TContainer, Resizable<TSpec> > & view, TValue const & _value, Tag<TExpand> tag)
{
resize(view, length(view) + 1, tag);
value(view, length(view) - 1) = _value;
}
// NOTE(esiragusa): It is not necessary to overload it, but otherwise I had to qualify the generic one :(
template <typename TContainer, typename TSpec, typename TValue>
inline void
appendValue(ContainerView<TContainer, Resizable<TSpec> > & view, TValue const & _value)
{
typedef ContainerView<TContainer, Resizable<TSpec> > TView;
appendValue(view, _value, typename DefaultOverflowImplicit<TView>::Type());
}
// ----------------------------------------------------------------------------
// Function clear()
// ----------------------------------------------------------------------------
template <typename TContainer, typename TSpec>
inline void
clear(ContainerView<TContainer, Resizable<TSpec> > & view)
{
resize(view, 0, Exact());
}
// ----------------------------------------------------------------------------
// Operator<<
// ----------------------------------------------------------------------------
template <typename TStream, typename TContainer, typename TSpec>
inline TStream &
operator<<(TStream & target, ContainerView<TContainer, TSpec> const & source)
{
typename DirectionIterator<TStream, Output>::Type it = directionIterator(target, Output());
write(it, source);
return target;
}
// ----------------------------------------------------------------------------
// Pipe interface
// ----------------------------------------------------------------------------
//template < typename TContainer,
// typename TSpec,
// typename TInput,
// typename TPipeSpec >
//inline void assign(ContainerView<TContainer, TSpec> &dest, Pipe<TInput, TPipeSpec> &src)
//{
// typedef typename Iterator<ContainerView<TContainer, TSpec>, Standard>::Type TDestIter;
// resize(dest, length(src));
// beginRead(src);
// for (TDestIter _cur = begin(dest, Standard()), _end = end(dest, Standard()); _cur != _end; ++_cur, ++src)
// *_cur = *src;
// endRead(src);
//}
//
//template < typename TContainer,
// typename TSpec,
// typename TInput,
// typename TPipeSpec >
//inline void operator << (ContainerView<TContainer, TSpec> &dest, Pipe<TInput, TPipeSpec> &src)
//{
// assign(dest, src);
//}
} // namespace seqan
#endif // #ifndef SEQAN_SEQUENCE_CONTAINER_VIEW_H
|