1 /*==========================================================================
2 SeqAn - The Library for Sequence Analysis
4 ============================================================================
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.
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.
17 ============================================================================
18 $Id: segment_base.h,v 1.1 2008/08/25 16:20:04 langmead Exp $
19 ==========================================================================*/
21 #ifndef SEQAN_HEADER_SEGMENT_BASE_H
22 #define SEQAN_HEADER_SEGMENT_BASE_H
25 namespace SEQAN_NAMESPACE_MAIN
28 //////////////////////////////////////////////////////////////////////////////
30 //////////////////////////////////////////////////////////////////////////////
35 ..summary:A contiguous part of a sequence.
36 ..signature:Segment<THost, TSpec>
37 ..param.THost:Type of the whole sequence.
38 ...metafunction:Metafunction.Host
39 ...text:Instances of $Segment<THost, TSpec>$ are subsequences of $THost$ objects.
40 ..param.TSpec:The specializing type.
41 ...metafunction:Metafunction.Spec
42 ...default:@Spec.InfixSegment@.
47 template <typename THost, typename TSpec = InfixSegment>
52 //////////////////////////////////////////////////////////////////////////////
54 ///.Metafunction.Host.param.T.type:Class.Segment
56 template <typename THost, typename TSpec>
57 struct Host<Segment<THost, TSpec> >
62 template <typename THost, typename TSpec>
63 struct Host<Segment<THost, TSpec> const >
68 //////////////////////////////////////////////////////////////////////////////
70 ///.Metafunction.Spec.param.T.type:Class.Segment
72 template <typename THost, typename TSpec>
73 struct Spec<Segment<THost, TSpec> >
77 template <typename THost, typename TSpec>
78 struct Spec<Segment<THost, TSpec> const>
83 //////////////////////////////////////////////////////////////////////////////
85 ///.Metafunction.Value.param.T.type:Class.Segment
87 template <typename THost, typename TSpec>
88 struct Value<Segment<THost, TSpec> >
90 typedef typename Value<THost>::Type Type;
93 template <typename THost, typename TSpec>
94 struct Value<Segment<THost, TSpec> const >
96 typedef typename Value<THost const>::Type Type;
99 //////////////////////////////////////////////////////////////////////////////
101 ///.Metafunction.GetValue.param.T.type:Class.Segment
103 template <typename THost, typename TSpec>
104 struct GetValue<Segment<THost, TSpec> >
106 typedef typename GetValue<THost>::Type Type;
109 template <typename THost, typename TSpec>
110 struct GetValue<Segment<THost, TSpec> const >
112 typedef typename GetValue<THost const>::Type Type;
115 //////////////////////////////////////////////////////////////////////////////
117 ///.Metafunction.Iterator.param.T.type:Class.Segment
119 template <typename THost, typename TSpec>
120 struct Iterator<Segment<THost, TSpec>, Rooted>
122 typedef Segment<THost, TSpec> TSequence;
123 typedef typename Iterator<THost, Standard>::Type TIterator;
124 typedef Iter<TSequence, AdaptorIterator<TIterator> > Type;
126 template <typename THost, typename TSpec>
127 struct Iterator<Segment<THost, TSpec> const, Rooted>
129 typedef Segment<THost, TSpec> const TSequence;
130 typedef typename Iterator<THost const, Standard>::Type TIterator;
131 typedef Iter<TSequence, AdaptorIterator<TIterator> > Type;
134 template <typename THost, typename TSpec>
135 struct Iterator<Segment<THost, TSpec>, Standard>:
136 Iterator<THost, Standard>
139 template <typename THost, typename TSpec>
140 struct Iterator<Segment<THost, TSpec> const, Standard>:
141 Iterator<THost, Standard>
147 //////////////////////////////////////////////////////////////////////////////
149 ///.Metafunction.Size.param.T.type:Class.Segment
151 template <typename THost, typename TSpec>
152 struct Size<Segment<THost, TSpec> >
154 typedef typename Size<THost>::Type Type;
157 template <typename THost, typename TSpec>
158 struct Size<Segment<THost, TSpec> const >
160 typedef typename Size<THost>::Type Type;
163 template <typename THost, typename TSpec>
164 struct Position<Segment<THost, TSpec> >
166 typedef typename Position<THost>::Type Type;
169 template <typename THost, typename TSpec>
170 struct Position<Segment<THost, TSpec> const >
172 typedef typename Position<THost>::Type Type;
175 //////////////////////////////////////////////////////////////////////////////
177 ///.Metafunction.DefaultOverflowImplicit.param.T.type:Class.Segment
179 template <typename THost, typename TSpec>
180 struct DefaultOverflowImplicit<Segment<THost, TSpec > >:
181 DefaultOverflowImplicit<THost>
185 template <typename THost, typename TSpec>
186 struct DefaultOverflowImplicit<Segment<THost, TSpec > const >:
187 DefaultOverflowImplicit<THost>
191 //////////////////////////////////////////////////////////////////////////////
193 ///.Metafunction.DefaultOverflowExplicit.param.T.type:Class.Segment
195 template <typename THost, typename TSpec>
196 struct DefaultOverflowExplicit<Segment<THost, TSpec > >:
197 DefaultOverflowExplicit<THost>
201 template <typename THost, typename TSpec>
202 struct DefaultOverflowExplicit<Segment<THost, TSpec > const >:
203 DefaultOverflowExplicit<THost>
207 //////////////////////////////////////////////////////////////////////////////
209 ///.Metafunction.IsContiguous.param.T.type:Class.Segment
211 template <typename THost, typename TSpec>
212 struct IsContiguous< Segment<THost, TSpec> >:
213 public IsContiguous<THost> {};
215 //////////////////////////////////////////////////////////////////////////////
217 ///.Metafunction.IsSequence.param.T.type:Class.Segment
219 template <typename THost, typename TSpec>
220 struct IsSequence< Segment<THost, TSpec> > {
222 enum { VALUE = true };
225 //////////////////////////////////////////////////////////////////////////////
227 ///.Function.atBegin.param.iterator.type:Class.Segment
228 ///.Function.atEnd.param.iterator.type:Class.Segment
229 ///.Function.goBegin.param.iterator.type:Class.Segment
230 ///.Function.goEnd.param.iterator.type:Class.Segment
231 ///.Function.goNext.param.iterator.type:Class.Segment
232 ///.Function.goPrevious.param.iterator.type:Class.Segment
233 ///.Function.value.param.container.type:Class.Segment
235 ///.Function.shareResources.param.sequence1, sequence2.type:Class.Segment
237 //////////////////////////////////////////////////////////////////////////////
238 // functions for all Segment classes
239 //////////////////////////////////////////////////////////////////////////////
241 ///.Function.id.param.object.type:Class.Segment
243 template <typename THost, typename TSpec>
245 id(Segment<THost, TSpec> const & me)
251 //////////////////////////////////////////////////////////////////////////////
253 ///.Function.length.param.object.type:Class.Segment
255 template <typename THost, typename TSpec>
256 inline typename Size<Segment<THost, TSpec> const>::Type
257 length(Segment<THost, TSpec> const & me)
260 return endPosition(me) - beginPosition(me);
263 //////////////////////////////////////////////////////////////////////////////
265 ///.Function.capacity.param.object.type:Class.Segment
267 template <typename THost, typename TSpec>
268 inline typename Size< Segment<THost, TSpec> const>::Type
269 capacity(Segment<THost, TSpec> const & me)
272 return capacity(host(me)) + length(me) - length(host(me));
275 //////////////////////////////////////////////////////////////////////////////
277 //////////////////////////////////////////////////////////////////////////////
281 ..remarks:If $target$ is a @Class.Segment@ object, then
282 $limit$ denotes the maximal length of @Function.host.$host(target)$@ after the operation.
283 ..param.target.type:Class.Segment
284 ..param.source.type:Class.Segment
287 //overload of binary version for strings:
289 template<typename THost, typename TSpec, typename TSource>
291 assign(Segment<THost, TSpec> & target,
295 typedef Segment<THost, TSpec> TTarget;
296 assign(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
298 template<typename THost, typename TSpec, typename TSource>
300 assign(Segment<THost, TSpec> & target,
301 TSource const & source)
304 typedef Segment<THost, TSpec> TTarget;
305 assign(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
308 //(for temporary targets)
310 template<typename THost, typename TSpec, typename TSource>
312 assign(Segment<THost, TSpec> const & target,
316 typedef Segment<THost, TSpec> const TTarget;
317 assign(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
319 template<typename THost, typename TSpec, typename TSource>
321 assign(Segment<THost, TSpec> const & target,
322 TSource const & source)
325 typedef Segment<THost, TSpec> const TTarget;
326 assign(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
329 //////////////////////////////////////////////////////////////////////////////
331 template <typename TExpand>
332 struct _Assign_Segment
334 template <typename THost, typename TSpec, typename TSource>
337 Segment<THost, TSpec> & target,
341 if ((void *) &target == (void *) &source) return;
343 typedef Segment<THost, TSpec> Target;
345 replace(host(target), beginPosition(target), endPosition(target), source, TExpand());
347 typename Iterator<Target, Standard>::Type new_end = begin(target, Standard()) + length(source);
348 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
349 if (new_end > host_end) new_end = host_end;
350 setEnd(target, new_end);
353 template <typename THost, typename TSpec, typename TSource>
356 Segment<THost, TSpec> & target,
358 typename Size< Segment<THost, TSpec> >::Type limit)
361 if ((void *) &target == (void *) &source) return;
363 typedef Segment<THost, TSpec> Target;
365 replace(host(target), beginPosition(target), endPosition(target), source, limit, TExpand());
367 typename Iterator<Target, Standard>::Type new_end = begin(target, Standard()) + length(source);
368 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
369 if (begin(target, Standard()) > host_end) setBegin(target, host_end);
370 if (new_end > host_end) new_end = host_end;
371 setEnd(target, new_end);
374 template <typename THost, typename TSpec, typename TSource>
377 Segment<THost, TSpec> const & target,
381 replace(host(target), beginPosition(target), endPosition(target), source, TExpand());
384 template <typename THost, typename TSpec, typename TSource>
387 Segment<THost, TSpec> const & target,
389 typename Size< Segment<THost, TSpec> >::Type limit)
392 replace(host(target), beginPosition(target), endPosition(target), source, limit, TExpand());
396 //____________________________________________________________________________
398 template <typename THost, typename TSpec, typename TSource, typename TExpand>
400 assign(Segment<THost, TSpec> & target,
405 _Assign_Segment<Tag<TExpand> const>::assign_(target, source);
407 template <typename THost, typename TSpec, typename TSource, typename TExpand>
409 assign(Segment<THost, TSpec> & target,
410 TSource const & source,
414 _Assign_Segment<Tag<TExpand> const>::assign_(target, source);
417 template <typename THost, typename TSpec, typename TSource, typename TExpand>
419 assign(Segment<THost, TSpec> & target,
421 typename Size< Segment<THost, TSpec> >::Type limit,
425 _Assign_Segment<Tag<TExpand> const>::assign_(target, source, limit);
427 template <typename THost, typename TSpec, typename TSource, typename TExpand>
429 assign(Segment<THost, TSpec> & target,
430 TSource const & source,
431 typename Size< Segment<THost, TSpec> >::Type limit,
435 _Assign_Segment<Tag<TExpand> const>::assign_(target, source, limit);
438 //(for temporary targets)
440 template <typename THost, typename TSpec, typename TSource, typename TExpand>
442 assign(Segment<THost, TSpec> const & target,
447 _Assign_Segment<Tag<TExpand> const>::assign_(target, source);
449 template <typename THost, typename TSpec, typename TSource, typename TExpand>
451 assign(Segment<THost, TSpec> const & target,
452 TSource const & source,
456 _Assign_Segment<Tag<TExpand> const>::assign_(target, source);
459 template <typename THost, typename TSpec, typename TSource, typename TExpand>
461 assign(Segment<THost, TSpec> const & target,
463 typename Size< Segment<THost, TSpec> >::Type limit,
467 _Assign_Segment<Tag<TExpand> const>::assign_(target, source, limit);
469 template <typename THost, typename TSpec, typename TSource, typename TExpand>
471 assign(Segment<THost, TSpec> const & target,
472 TSource const & source,
473 typename Size< Segment<THost, TSpec> >::Type limit,
477 _Assign_Segment<Tag<TExpand> const>::assign_(target, source, limit);
480 //////////////////////////////////////////////////////////////////////////////
482 //////////////////////////////////////////////////////////////////////////////
484 //overload of binary version:
486 template <typename THost, typename TSpec, typename TSource, typename TExpand>
488 move(Segment<THost, TSpec> & target,
492 typedef Segment<THost, TSpec> TTarget;
493 move(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
495 template <typename THost, typename TSpec, typename TSource, typename TExpand>
497 move(Segment<THost, TSpec> & target,
498 TSource const & source)
501 typedef Segment<THost, TSpec> TTarget;
502 move(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
505 //(for temporary targets)
507 template <typename THost, typename TSpec, typename TSource, typename TExpand>
509 move(Segment<THost, TSpec> const & target,
513 typedef Segment<THost, TSpec> const TTarget;
514 move(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
516 template <typename THost, typename TSpec, typename TSource, typename TExpand>
518 move(Segment<THost, TSpec> const & target,
519 TSource const & source)
522 typedef Segment<THost, TSpec> const TTarget;
523 move(target, source, typename DefaultOverflowImplicit<TTarget>::Type());
528 //////////////////////////////////////////////////////////////////////////////
530 //////////////////////////////////////////////////////////////////////////////
534 ..remarks:If $target$ is a @Class.Segment@ object, then
535 $limit$ denotes the maximal length of @Function.host.$host(target)$@ after the operation.
536 ..param.target.type:Class.Segment
537 ..param.source.type:Class.Segment
541 template <typename TExpand>
542 struct _Append_Sequence_2_Segment
544 template <typename THost, typename TSpec, typename TSource>
547 Segment<THost, TSpec> & target,
551 typedef Segment<THost, TSpec> Target;
553 replace(host(target), endPosition(target), endPosition(target), source, TExpand());
555 typename Iterator<Target, Standard>::Type new_end = end(target, Standard()) + length(source);
556 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
557 if (new_end > host_end) new_end = host_end;
558 setEnd(target, new_end);
561 template <typename THost, typename TSpec, typename TSource>
564 Segment<THost, TSpec> & target,
565 TSource const & source,
566 typename Size< Segment<THost, TSpec> >::Type limit)
569 typedef Segment<THost, TSpec> Target;
571 replace(host(target), endPosition(target), endPosition(target), source, limit, TExpand());
572 typename Iterator<Target, Standard>::Type new_end = end(target, Standard()) + length(source);
573 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
574 if (begin(target) > host_end) setBegin(target, host_end);
575 if (new_end > host_end) new_end = host_end;
576 setEnd(target, new_end);
579 template <typename THost, typename TSpec, typename TSource>
582 Segment<THost, TSpec> const & target,
586 replace(host(target), endPosition(target), endPosition(target), source, TExpand());
589 template <typename THost, typename TSpec, typename TSource>
592 Segment<THost, TSpec> const & target,
593 TSource const & source,
594 typename Size< Segment<THost, TSpec> >::Type limit)
597 replace(host(target), endPosition(target), endPosition(target), source, limit, TExpand()); //??? INSERT
600 //____________________________________________________________________________
603 template <typename THost, typename TSpec, typename TSource, typename TExpand>
606 Segment<THost, TSpec> & target,
611 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source);
613 template <typename THost, typename TSpec, typename TSource, typename TExpand>
616 Segment<THost, TSpec> & target,
617 TSource const & source,
621 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source);
624 template <typename THost, typename TSpec, typename TSource, typename TExpand>
627 Segment<THost, TSpec> & target,
629 typename Size< Segment<THost, TSpec> >::Type limit,
633 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source, limit);
635 template <typename THost, typename TSpec, typename TSource, typename TExpand>
638 Segment<THost, TSpec> & target,
639 TSource const & source,
640 typename Size< Segment<THost, TSpec> >::Type limit,
644 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source, limit);
647 template <typename THost, typename TSpec, typename TSource, typename TExpand>
650 Segment<THost, TSpec> const & target,
655 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source);
657 template <typename THost, typename TSpec, typename TSource, typename TExpand>
660 Segment<THost, TSpec> const & target,
661 TSource const & source,
665 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source);
668 template <typename THost, typename TSpec, typename TSource, typename TExpand>
671 Segment<THost, TSpec> const & target,
673 typename Size< Segment<THost, TSpec> >::Type limit,
677 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source, limit);
679 template <typename THost, typename TSpec, typename TSource, typename TExpand>
682 Segment<THost, TSpec> const & target,
683 TSource const & source,
684 typename Size< Segment<THost, TSpec> >::Type limit,
688 _Append_Sequence_2_Segment<Tag<TExpand> const>::append_(target, source, limit);
691 //////////////////////////////////////////////////////////////////////////////
693 //////////////////////////////////////////////////////////////////////////////
695 template <typename TExpand>
696 struct _Append_Value_2_Segment
698 template <typename T, typename TValue>
704 insertValue(host(me), endPosition(me), TExpand());
705 if (endPosition(me) < length(host(me)) ) //this could be false for some TExpand
707 setEndPosition(me, endPosition(me) + 1);
712 //____________________________________________________________________________
714 template <typename THost, typename TSpec, typename TValue, typename TExpand>
716 appendValue(Segment<THost, TSpec> & me,
717 TValue const & _value,
721 _Append_Value_2_Segment<Tag<TExpand> const>::appendValue_(me, _value);
723 template <typename THost, typename TSpec, typename TValue, typename TExpand>
725 appendValue(Segment<THost, TSpec> const & me,
726 TValue const & _value,
730 _Append_Value_2_Segment<Tag<TExpand> const>::appendValue_(me, _value);
733 //////////////////////////////////////////////////////////////////////////////
735 //////////////////////////////////////////////////////////////////////////////
737 template <typename TExpand>
738 struct _Insert_Value_2_Segment
740 template <typename T, typename TPosition, typename TValue>
747 insertValue(host(me), beginPosition(me) + pos, TExpand());
748 if (endPosition(me) < length(host(me)) ) //this could be false for some TExpand
750 setEndPosition(me, endPosition(me) + 1);
755 //____________________________________________________________________________
757 template <typename THost, typename TSpec, typename TPosition, typename TValue, typename TExpand>
759 insertValue(Segment<THost, TSpec> & me,
761 TValue const & _value,
765 _Insert_Value_2_Segment<Tag<TExpand> const>::insertValue_(me, pos, _value);
767 template <typename THost, typename TSpec, typename TPosition, typename TValue, typename TExpand>
769 insertValue(Segment<THost, TSpec> const & me,
771 TValue const & _value,
775 _Insert_Value_2_Segment<Tag<TExpand> const>::insertValue_(me, pos, _value);
778 //////////////////////////////////////////////////////////////////////////////
780 //////////////////////////////////////////////////////////////////////////////
784 ..remarks:If $target$ is a @Class.Segment@ object, then
785 $limit$ denotes the maximal length of @Function.host.$host(target)$@ after the operation.
786 ..param.target.type:Class.Segment
787 ..param.source.type:Class.Segment
790 template <typename TExpand>
791 struct _Replace_Sequence_2_Segment
793 template <typename THost, typename TSpec, typename TSource>
796 Segment<THost, TSpec> & target,
797 typename Position< Segment<THost, TSpec> >::Type pos_begin,
798 typename Position< Segment<THost, TSpec> >::Type pos_end,
802 typedef Segment<THost, TSpec> Target;
804 replace(host(target), beginPosition(target) + pos_begin, beginPosition(target) + pos_end, source, TExpand());
806 typename Iterator<Target, Standard>::Type new_end = begin(target, Standard()) + length(target) - pos_end + pos_begin + length(source);
807 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
808 if (new_end > host_end) new_end = host_end;
809 setEnd(target, new_end);
812 template <typename THost, typename TSpec, typename TSource>
815 Segment<THost, TSpec> & target,
816 typename Position< Segment<THost, TSpec> >::Type pos_begin,
817 typename Position< Segment<THost, TSpec> >::Type pos_end,
819 typename Size< Segment<THost, TSpec> >::Type limit)
822 typedef Segment<THost, TSpec> Target;
824 replace(host(target), beginPosition(target) + pos_begin, beginPosition(target) + pos_end, source, limit, TExpand());
826 typename Iterator<Target, Standard>::Type new_end = begin(target, Standard()) + length(target) - pos_end + pos_begin + length(source);
827 typename Iterator<THost, Standard>::Type host_end = end(host(target), Standard());
828 if (begin(target, Standard()) > host_end) setBegin(target, host_end);
829 if (new_end > host_end) new_end = host_end;
830 setEnd(target, new_end);
833 template <typename THost, typename TSpec, typename TSource>
836 Segment<THost, TSpec> const & target,
837 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
838 typename Position< Segment<THost, TSpec> const>::Type pos_end,
842 replace(host(target), beginPosition(target) + pos_begin, beginPosition(target) + pos_end, source, TExpand());
845 template <typename THost, typename TSpec, typename TSource>
848 Segment<THost, TSpec> const & target,
849 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
850 typename Position< Segment<THost, TSpec> const>::Type pos_end,
852 typename Size< Segment<THost, TSpec> >::Type limit)
855 replace(host(target), beginPosition(target) + pos_begin, beginPosition(target) + pos_end, source, limit, TExpand()); //??? INSERT
858 //____________________________________________________________________________
861 template <typename THost, typename TSpec, typename TSource, typename TExpand>
864 Segment<THost, TSpec> & target,
865 typename Position< Segment<THost, TSpec> >::Type pos_begin,
866 typename Position< Segment<THost, TSpec> >::Type pos_end,
871 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source);
873 template <typename THost, typename TSpec, typename TSource, typename TExpand>
876 Segment<THost, TSpec> & target,
877 typename Position< Segment<THost, TSpec> >::Type pos_begin,
878 typename Position< Segment<THost, TSpec> >::Type pos_end,
879 TSource const & source,
883 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source);
886 template <typename THost, typename TSpec, typename TSource, typename TExpand>
889 Segment<THost, TSpec> & target,
890 typename Position< Segment<THost, TSpec> >::Type pos_begin,
891 typename Position< Segment<THost, TSpec> >::Type pos_end,
893 typename Size< Segment<THost, TSpec> >::Type limit,
897 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source, limit);
899 template <typename THost, typename TSpec, typename TSource, typename TExpand>
902 Segment<THost, TSpec> & target,
903 typename Position< Segment<THost, TSpec> >::Type pos_begin,
904 typename Position< Segment<THost, TSpec> >::Type pos_end,
905 TSource const & source,
906 typename Size< Segment<THost, TSpec> >::Type limit,
910 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source, limit);
913 template <typename THost, typename TSpec, typename TSource, typename TExpand>
916 Segment<THost, TSpec> const & target,
917 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
918 typename Position< Segment<THost, TSpec> const>::Type pos_end,
923 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source);
925 template <typename THost, typename TSpec, typename TSource, typename TExpand>
928 Segment<THost, TSpec> const & target,
929 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
930 typename Position< Segment<THost, TSpec> const>::Type pos_end,
931 TSource const & source,
935 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source);
938 template <typename THost, typename TSpec, typename TSource, typename TExpand>
941 Segment<THost, TSpec> const & target,
942 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
943 typename Position< Segment<THost, TSpec> const>::Type pos_end,
945 typename Size< Segment<THost, TSpec> >::Type limit,
949 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source, limit);
951 template <typename THost, typename TSpec, typename TSource, typename TExpand>
954 Segment<THost, TSpec> const & target,
955 typename Position< Segment<THost, TSpec> const>::Type pos_begin,
956 typename Position< Segment<THost, TSpec> const>::Type pos_end,
957 TSource const & source,
958 typename Size< Segment<THost, TSpec> >::Type limit,
962 _Replace_Sequence_2_Segment<Tag<TExpand> const>::replace_(target, pos_begin, pos_end, source, limit);
965 //////////////////////////////////////////////////////////////////////////////
966 // handling of iterators as begin and end
969 template<typename THost, typename TTargetSpec, typename TSource, typename TExpand>
971 replace(Segment<THost, TTargetSpec> & target,
972 typename Iterator< Segment<THost, TTargetSpec>, Rooted>::Type pos_begin,
973 typename Iterator< Segment<THost, TTargetSpec>, Rooted>::Type pos_end,
975 Tag<TExpand> const tag)
978 replace(target, position(pos_begin), position(pos_end), source, tag);
981 template<typename THost, typename TTargetSpec, typename TSource, typename TExpand>
983 replace(Segment<THost, TTargetSpec> & target,
984 typename Iterator< Segment<THost, TTargetSpec>, Rooted>::Type pos_begin,
985 typename Iterator< Segment<THost, TTargetSpec>, Rooted>::Type pos_end,
987 typename Size< Segment<THost, TTargetSpec> >::Type limit,
988 Tag<TExpand> const tag)
991 replace(target, position(pos_begin), position(pos_end), source, limit, tag);
994 template<typename THost, typename TTargetSpec, typename TSource, typename TExpand>
996 replace(Segment<THost, TTargetSpec> const & target,
997 typename Iterator< Segment<THost, TTargetSpec> const, Rooted>::Type pos_begin,
998 typename Iterator< Segment<THost, TTargetSpec> const, Rooted>::Type pos_end,
1000 Tag<TExpand> const tag)
1003 replace(target, position(pos_begin), position(pos_end), source, tag);
1006 template<typename THost, typename TTargetSpec, typename TSource, typename TExpand>
1008 replace(Segment<THost, TTargetSpec> const & target,
1009 typename Iterator< Segment<THost, TTargetSpec> const, Rooted>::Type pos_begin,
1010 typename Iterator< Segment<THost, TTargetSpec> const, Rooted>::Type pos_end,
1012 typename Size< Segment<THost, TTargetSpec> >::Type limit,
1013 Tag<TExpand> const tag)
1016 replace(target, position(pos_begin), position(pos_end), source, limit, tag);
1020 //////////////////////////////////////////////////////////////////////////////
1021 ///.Function.resize.param.object.type:Class.Segment
1023 template <typename THost, typename TSpec, typename TExpand>
1024 inline typename Size< Segment<THost, TSpec> >::Type
1026 Segment<THost, TSpec> & me,
1027 typename Size< Segment<THost, TSpec> >::Type new_length,
1028 Tag<TExpand> const tag)
1032 typename Size<Segment<THost, TSpec> >::Type me_length = length(me);
1033 typename Position<THost>::Type me_end_pos = endPosition(me);
1034 if (new_length > me_length)
1036 new_length = me_length + resizeSpace(host(me), new_length - me_length, me_end_pos, me_end_pos, tag);
1038 else if (new_length < me_length)
1040 new_length = resizeSpace(host(me), 0, me_end_pos - (me_length - new_length), me_end_pos, tag);
1042 _setLength(me, new_length);
1046 //////////////////////////////////////////////////////////////////////////////
1047 //??? TODO: fill (kopie von resize anpassen)
1049 //////////////////////////////////////////////////////////////////////////////
1050 ///.Function.clear.param.object.type:Class.Segment
1052 template <typename THost, typename TSpec>
1054 clear(Segment<THost, TSpec> & target)
1060 //////////////////////////////////////////////////////////////////////////////
1062 template <typename TLeftValue, typename TLeftSpec, typename TRight>
1063 Segment<TLeftValue, TLeftSpec> const &
1064 operator += (Segment<TLeftValue, TLeftSpec> & left,
1065 TRight const & right)
1068 append(left, right);
1072 //////////////////////////////////////////////////////////////////////////////
1073 //////////////////////////////////////////////////////////////////////////////
1075 template <typename TLeftHost, typename TLeftSpec, typename TRight >
1077 operator == (Segment<TLeftHost, TLeftSpec> const & left,
1078 TRight const & right)
1081 typename Comparator<Segment<TLeftHost, TLeftSpec> >::Type _lex(left, right);
1082 return isEqual(_lex);
1085 //////////////////////////////////////////////////////////////////////////////
1087 template <typename TLeftHost, typename TLeftSpec, typename TRight >
1089 operator != (Segment<TLeftHost, TLeftSpec> const & left,
1090 TRight const & right)
1093 typename Comparator<Segment<TLeftHost, TLeftSpec> >::Type _lex(left, right);
1094 return isNotEqual(_lex);
1097 //////////////////////////////////////////////////////////////////////////////
1099 template <typename TLeftHost, typename TLeftSpec, typename TRight>
1101 operator < (Segment<TLeftHost, TLeftSpec> const & left,
1102 TRight const & right)
1105 return isLess(left, right, typename DefaultPrefixOrder<Segment<TLeftHost, TLeftSpec> >::Type());
1108 //////////////////////////////////////////////////////////////////////////////
1110 template <typename TLeftHost, typename TLeftSpec, typename TRight>
1112 operator <= (Segment<TLeftHost, TLeftSpec> const & left,
1113 TRight const & right)
1116 return isLessOrEqual(left, right, typename DefaultPrefixOrder<Segment<TLeftHost, TLeftSpec> >::Type());
1118 //////////////////////////////////////////////////////////////////////////////
1120 template <typename TLeftHost, typename TLeftSpec, typename TRight>
1122 operator > (Segment<TLeftHost, TLeftSpec> const & left,
1123 TRight const & right)
1126 return isGreater(left, right, typename DefaultPrefixOrder<Segment<TLeftHost, TLeftSpec> >::Type());
1129 //////////////////////////////////////////////////////////////////////////////
1131 template <typename TLeftHost, typename TLeftSpec, typename TRight>
1133 operator >= (Segment<TLeftHost, TLeftSpec> const & left,
1134 TRight const & right)
1137 return isGreaterOrEqual(left, right, typename DefaultPrefixOrder<Segment<TLeftHost, TLeftSpec> >::Type());
1141 //////////////////////////////////////////////////////////////////////////////
1143 //////////////////////////////////////////////////////////////////////////////
1145 template <typename TStream, typename THost, typename TSpec>
1147 operator << (TStream & target,
1148 Segment<THost, TSpec> const & source)
1151 write(target, source);
1155 //////////////////////////////////////////////////////////////////////////////
1157 template <typename TStream, typename THost, typename TSpec>
1159 operator >> (TStream & source,
1160 Segment<THost, TSpec> & target)
1163 read(source, target);
1166 template <typename TStream, typename THost, typename TSpec>
1168 operator >> (TStream & source,
1169 Segment<THost, TSpec> const & target)
1172 read(source, target);
1176 //////////////////////////////////////////////////////////////////////////////
1179 } //namespace SEQAN_NAMESPACE_MAIN
1181 #endif //#ifndef SEQAN_HEADER_...