Imported Upstream version 0.12.7
[bowtie.git] / SeqAn-1.1 / seqan / basic / basic_iterator_simple.h
1  /*==========================================================================
2                 SeqAn - The Library for Sequence Analysis
3                           http://www.seqan.de 
4  ============================================================================
5   Copyright (C) 2007
6
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.
11
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.
16
17  ============================================================================
18   $Id: basic_iterator_simple.h,v 1.1 2008/08/25 16:20:01 langmead Exp $
19  ==========================================================================*/
20
21 #ifndef SEQAN_HEADER_BASIC_ITERATOR_SIMPLE_H
22 #define SEQAN_HEADER_BASIC_ITERATOR_SIMPLE_H
23
24 namespace SEQAN_NAMESPACE_MAIN
25 {
26 //////////////////////////////////////////////////////////////////////////////
27 // Iter
28 //////////////////////////////////////////////////////////////////////////////
29
30 struct SimpleIterator;
31
32 /**
33 .Spec.SimpleIterator:
34 ..cat:Iterators
35 ..summary:A simple iterator.
36 ..signature:Iter<TContainer, SimpleIterator>
37 ..param.TContainer:Type of the container that can be iterated.
38 ...metafunction:Metafunction.Container
39 ..general:Class.Iter
40 */
41 template <typename TContainer>
42 class Iter<TContainer, SimpleIterator>
43 {
44 public:
45         typedef typename Value<TContainer>::Type TValue;
46         TValue * data_ptr;
47
48         Iter()
49         {
50         }
51         Iter(Iter const & other_):
52                 data_ptr(other_.data_ptr)
53         {
54         }
55         Iter(TValue * other_data_ptr):
56                 data_ptr(other_data_ptr)
57         {
58         }
59         template <typename TContainer2>
60         Iter(Iter<TContainer2, SimpleIterator> const & other_):
61                 data_ptr(other_.data_ptr)
62         {
63         }
64         ~Iter()
65         {
66         }
67         Iter const &
68         operator = (Iter const & other_)
69         {
70                 this->data_ptr = other_.data_ptr;
71                 return *this;
72         }
73         Iter const &
74         operator = (TValue * other_data_ptr)
75         {
76                 data_ptr = other_data_ptr;
77                 return *this;
78         }
79         template <typename TContainer2>
80         Iter const &
81         operator = (Iter<TContainer2, SimpleIterator> const & other_)
82         {
83                 this->data_ptr = other_.data_ptr;
84                 return *this;
85         }
86
87         operator TValue * ()
88         {
89                 return data_ptr;
90         }
91 };
92
93 //////////////////////////////////////////////////////////////////////////////
94
95 template <typename T>
96 struct Iterator_Default_Imp<T, Standard>
97 {
98         typedef typename Value<T>::Type * Type;
99 //      typedef Iter<T, SimpleIterator> Type;
100 };
101
102 //////////////////////////////////////////////////////////////////////////////
103
104 template <typename TContainer, typename TContainer2>
105 inline typename Position<Iter<TContainer, SimpleIterator> const>::Type 
106 position(Iter<TContainer, SimpleIterator> const & me,
107                  TContainer2 const & cont)
108 {
109 SEQAN_CHECKPOINT
110         return me.data_ptr - begin(cont);
111 }
112
113 //////////////////////////////////////////////////////////////////////////////
114
115 } //namespace SEQAN_NAMESPACE_MAIN
116
117 #endif //#ifndef SEQAN_HEADER_...