Class Segment
A contiguous part of a sequence.

Implements RandomAccessContainerConcept, SegmentableConcept
All Subcl's InfixSegment, PrefixSegment, SuffixSegment
All Impl'd AssignableConcept, ContainerConcept, DestructibleConcept, ForwardContainerConcept, RandomAccessContainerConcept, ReversibleContainerConcept, SegmentableConcept
Defined in <seqan/sequence.h>
Signature template <typename THost, typename TSpec> class Segment;

Template Parameters

THost The underlying sequence type.
TSpec The tag to use for selecting the Segment specialization.

Member Function Overview

Member Functions Inherited From AssignableConcept

Member Functions Inherited From RandomAccessContainerConcept

Interface Function Overview

Interface Functions Inherited From AssignableConcept

Interface Functions Inherited From ContainerConcept

Interface Functions Inherited From RandomAccessContainerConcept

Interface Functions Inherited From SegmentableConcept

Interface Metafunction Overview

Interface Metafunctions Inherited From ContainerConcept

Interface Metafunctions Inherited From SegmentableConcept

Detailed Description

Also known as:

substring

Segments are lightweight representations of an underlying sequence (host). Only a pointer to the host and begin and/or end position have to be stored.

Segments support element access (reading and writing) as well as random access iteration.

    typedef Prefix<String<char> >::Type TPrefix;
    typedef Infix<String<char> >::Type  TInfix;
    typedef Suffix<String<char> >::Type TSuffix;

    String<char> text = "This is a text!";

    TPrefix preA(text, 4);
    TInfix infA(text, 10, 14);
    TSuffix sufA(text, 10);
    std::cout << preA << " " << infA << " " << sufA << "\n";  // => "This text text!"

    String<char> str;
    append(str, preA);
    append(str, infA);
    append(str, sufA);
    std::cout << str << "\n";  // => "This text text!"

    std::cout << preA[0] << " " << infA[0] << " " << sufA[0] << "\n";  // => "T t t"

    preA[0] = 'X';
    infA[0] = 'X';
    sufA[1] = 'X';
    std::cout << text << "\n";  // => "Xhis is a XXxt!"

    typedef Iterator<TInfix, Standard>::Type TIter;
    TIter it = begin(preA, Standard());
    it += 2;
    *it = 'Y';
    std::cout << text << "\n";  // => "XhYs is a XXxt!"

You can get the type of the infix/prefix/suffix of a sequence using Infix, Prefix, and Suffix. These metafunctions will "flatten" the type such that using these metafunctions, the infix of an infix is an infix and not an Infix Segment with an Infix Segment as its host. Instead, it will again be an Infix Segment of the host of the inner type.

A suffix of a suffix remains a suffix, a prefix of a prefix remains a prefix. Any other combination leads to the resulting type being a infix segment.

    typedef Infix<TInfix>::Type  TInfix2;  // == TInfix
    typedef Prefix<TInfix>::Type TInfix3;  // == TInfix
    typedef Suffix<TInfix>::Type TInfix4;  // == TInfix

    typedef Infix<TPrefix>::Type  TInfix5;   // == TInfix
    typedef Prefix<TPrefix>::Type TPrefix2;  // == TPrefix
    typedef Suffix<TPrefix>::Type TInfix6;   // == TInfix

    typedef Infix<TSuffix>::Type  TInfix7;   // == TInfix
    typedef Prefix<TSuffix>::Type TInfix8;   // == TPrefix
    typedef Suffix<TSuffix>::Type TSuffix2;  // == TSuffix

If you explicitely need a segment and keep the underlying sequence as it is, explicitely use the Segment template class.

    typedef Segment<TSuffix, PrefixSegment> TExplicitPrefix;
    TExplicitPrefix preB(sufA, 3);
    std::cout << preB << "\n";  // => "XXx"

Interface Functions Detail

TPos beginPosition(seg);

Return segment's begin position.

Parameters

seg The Segment to query for its begin position.

Returns

TPos The begin position of the segment. TPos is the position type of the Segment as returned by Position.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

TPos endPosition(seg);

Return segment's end position.

Parameters

seg The Segment to query for its end position.

Returns

TPos The end position of the segment. TPos is the position type of the Segment as returned by Position.

Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.