17 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HXX
18 # define VCSN_AUTOMATA_IMPLEMENTATION_LISTG_LISTG_SPARSE_INTERVAL_HXX
30 template <
class T,
class ExcludedContainer>
31 SparseIterator<handler<T, unsigned>, ExcludedContainer>::
32 SparseIterator (integer_t from,
33 const excluded_container_t& c)
38 template <
class T,
class ExcludedContainer>
39 SparseIterator<handler<T, unsigned>, ExcludedContainer>&
40 SparseIterator<handler<T, unsigned>, ExcludedContainer>::operator++ ()
42 if (excluded_->size () == 0)
47 while (excluded_->find (handler_t(integer_)) != excluded_->end ());
51 template <
class T,
class ExcludedContainer>
52 SparseIterator<handler<T, unsigned>, ExcludedContainer>&
53 SparseIterator<handler<T, unsigned>, ExcludedContainer>::operator-- ()
55 if (excluded_->size () == 0)
60 while (excluded_->find (handler_t(integer_)) != excluded_->end ());
64 template <
class T,
class ExcludedContainer>
65 SparseIterator<handler<T, unsigned>, ExcludedContainer>
66 SparseIterator<handler<T, unsigned>, ExcludedContainer>::operator++ (int)
68 SparseIterator tmp = *
this;
73 template <
class T,
class ExcludedContainer>
74 SparseIterator<handler<T, unsigned>, ExcludedContainer>
75 SparseIterator<handler<T, unsigned>, ExcludedContainer>::operator-- (int)
77 SparseIterator tmp = *
this;
82 template <
class T,
class ExcludedContainer>
83 typename SparseIterator<handler<T, unsigned>, ExcludedContainer>::
85 SparseIterator<handler<T, unsigned>, ExcludedContainer>::operator* ()
87 return handler_t(integer_);
90 template <
class T,
class ExcludedContainer>
92 SparseIterator<handler<T, unsigned>, ExcludedContainer>
93 ::operator!= (
const SparseIterator& i)
const
95 return i.integer_ != integer_;
98 template <
class T,
class ExcludedContainer>
100 SparseIterator<handler<T, unsigned>, ExcludedContainer>
101 ::operator== (
const SparseIterator& i)
const
103 return i.integer_ == integer_;
106 template <
class T,
class ExcludedContainer>
107 SparseIterator<handler<T, unsigned>, ExcludedContainer>&
108 SparseIterator<handler<T, unsigned>, ExcludedContainer>
109 ::operator= (
const SparseIterator& i)
111 integer_ = i.integer_;
112 excluded_ = i.excluded_;
127 template <
class T,
class ExcludedContainer>
128 SparseInterval<handler<T, unsigned>, ExcludedContainer>
134 precondition (from_ <= to_ + 1);
135 precondition (excluded_.find (handler_t(to_ + 1)) == excluded_.end ());
136 precondition ((to_ == limits<unsigned int>::max())
137 || (to_ + 1 - from_ >= excluded_.size()));
140 template <
class T,
class ExcludedContainer>
143 : excluded_ (a.excluded_),
149 template <
class T,
class ExcludedContainer>
151 SparseInterval<handler<T, unsigned>, ExcludedContainer>::size ()
const
155 return to_ == limits<unsigned int>::max() ? 0
156 : to_ - from_ + 1 - excluded_.size ();
159 template <
class T,
class ExcludedContainer>
161 SparseInterval<handler<T, unsigned>, ExcludedContainer>::to_string ()
const
164 s <<
"from :" << from_ <<
" to : " << to_ <<
" ex:";
165 for (
typename ExcludedContainer::iterator i = excluded_.begin ();
166 i != excluded_.end ();
172 template <
class T,
class ExcludedContainer>
173 typename SparseInterval<handler<T, unsigned>, ExcludedContainer>::iterator
174 SparseInterval<handler<T, unsigned>, ExcludedContainer>::begin ()
const
176 unsigned from = from_;
178 if (excluded_.size () != 0)
179 while (excluded_.find (handler_t(from)) != excluded_.end ())
181 return iterator (handler_t(from), excluded_);
184 template <
class T,
class ExcludedContainer>
185 typename SparseInterval<handler<T, unsigned>, ExcludedContainer>::iterator
186 SparseInterval<handler<T, unsigned>, ExcludedContainer>::end ()
const
188 return iterator (handler_t(to_ + 1), excluded_);
191 template <
class T,
class ExcludedContainer>
192 typename SparseInterval<handler<T, unsigned>, ExcludedContainer>::handler_t
193 SparseInterval<handler<T, unsigned>, ExcludedContainer>::back ()
const
197 if (excluded_.size () != 0)
198 while (excluded_.find (handler_t(to)) != excluded_.end ())
200 return *(iterator (handler_t(to), excluded_));
207 #endif // ! VCSN_MISC_SPARSE_INTERVAL_HXX