Rooted Iterators

| Example Program Rooted Iterators Example for some functions for handling (rooted) iterators. File "rooted_iterator.cpp" A tutorial about the use of rooted iterators.
1 | #include <iostream>
2 | #include <seqan/sequence.h>
3 | #include <seqan/file.h>
4 |
5 | using namespace seqan;
6 |
7 | int main()
8 | {
9 | typedef String<char> TText;
10 | TText str = "abcdefg";
The rooted iterator can be specified by passing the iterator spec Rooted as a second argument.
11 | Iterator<TText, Rooted>::Type it = begin(str);
The same iterator spec can be used as a tag for functions that return an iterator, e.g. begin or end.
12 | it = begin(str, Rooted());
A rooted iterator "knows" its container, so it supports the function container.
13 | std::cout << container(it); //output: "abcdefg"
14 | goNext(it);
It also supports functions such as goBegin or position.
15 | std::cout << position(it); //output: 7
16 | return 0;
17 | }
See end, container, Iterator Spec, Iterator, position See Also Iterator Basics SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2011/02/08 21:37:01