54 template<
typename ITER>
class tab_ref {
62 typedef typename std::iterator_traits<ITER>::value_type value_type;
63 typedef typename std::iterator_traits<ITER>::pointer pointer;
64 typedef typename std::iterator_traits<ITER>::pointer const_pointer;
65 typedef typename std::iterator_traits<ITER>::reference reference;
66 typedef typename std::iterator_traits<ITER>::reference const_reference;
67 typedef typename std::iterator_traits<ITER>::difference_type
69 typedef ITER iterator;
70 typedef ITER const_iterator;
71 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
72 typedef std::reverse_iterator<iterator> reverse_iterator;
75 bool empty(
void)
const {
return begin_ == end_; }
76 size_type size(
void)
const {
return end_ - begin_; }
78 const iterator &begin(
void) {
return begin_; }
79 const const_iterator &begin(
void)
const {
return begin_; }
80 const iterator &end(
void) {
return end_; }
81 const const_iterator &end(
void)
const {
return end_; }
82 reverse_iterator rbegin(
void) {
return reverse_iterator(end()); }
83 const_reverse_iterator rbegin(
void)
const
84 {
return const_reverse_iterator(end()); }
85 reverse_iterator rend(
void) {
return reverse_iterator(begin()); }
86 const_reverse_iterator rend(
void)
const
87 {
return const_reverse_iterator(begin()); }
89 reference front(
void) {
return *begin(); }
90 const_reference front(
void)
const {
return *begin(); }
91 reference back(
void) {
return *(--(end())); }
92 const_reference back(
void)
const {
return *(--(end())); }
93 void pop_front(
void) { ++begin_; }
95 const_reference operator [](
size_type ii)
const {
return *(begin_ + ii);}
96 reference operator [](
size_type ii) {
return *(begin_ + ii); }
99 tab_ref(
const ITER &b,
const ITER &e) : begin_(b), end_(e) {}
235 template<
typename ITER,
typename ITER_INDEX>
238 typedef typename std::iterator_traits<ITER>::value_type value_type;
239 typedef typename std::iterator_traits<ITER>::pointer pointer;
240 typedef typename std::iterator_traits<ITER>::reference reference;
241 typedef typename std::iterator_traits<ITER>::difference_type
243 typedef std::random_access_iterator_tag iterator_category;
245 typedef size_t size_type;
248 ITER_INDEX iter_index;
251 {
iterator tmp = *
this; ++iter_index;
return tmp; }
253 {
iterator tmp = *
this; --iter_index;
return tmp; }
254 iterator &operator ++() { ++iter_index;
return *
this; }
255 iterator &operator --() { --iter_index;
return *
this; }
256 iterator &operator +=(difference_type i)
257 { iter_index += i;
return *
this; }
258 iterator &operator -=(difference_type i)
259 { iter_index -= i;
return *
this; }
260 iterator operator +(difference_type i)
const
261 {
iterator it = *
this;
return (it += i); }
262 iterator operator -(difference_type i)
const
263 {
iterator it = *
this;
return (it -= i); }
264 difference_type operator -(
const iterator &i)
const
265 {
return iter_index - i.iter_index; }
267 reference operator *()
const
268 {
return *(piter + *iter_index); }
269 reference operator [](size_type ii)
const
270 {
return *(piter + *(iter_index+ii)); }
272 bool operator ==(
const iterator &i)
const
274 {
return (iter_index == i.iter_index); }
275 bool operator !=(
const iterator &i)
const {
return !(i == *
this); }
276 bool operator < (
const iterator &i)
const
277 {
return (iter_index < i.iter_index); }
278 bool operator > (
const iterator &i)
const
279 {
return (iter_index > i.iter_index); }
280 bool operator >=(
const iterator &i)
const
281 {
return (iter_index >= i.iter_index); }
285 const ITER_INDEX &dnas_iter)
286 : piter(iter), iter_index(dnas_iter) {}
294 template<
typename ITER,
typename ITER_INDEX>
307 typedef std::iterator_traits<ITER> traits_type;
308 typedef typename traits_type::value_type value_type;
309 typedef typename traits_type::pointer pointer;
310 typedef typename traits_type::pointer const_pointer;
311 typedef typename traits_type::reference reference;
312 typedef typename traits_type::reference const_reference;
313 typedef typename traits_type::difference_type difference_type;
314 typedef size_t size_type;
317 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
318 typedef std::reverse_iterator<iterator> reverse_iterator;
323 ITER_INDEX index_begin_, index_end_;
327 bool empty(
void)
const {
return index_begin_ == index_end_; }
328 size_type size(
void)
const {
return index_end_ - index_begin_; }
332 {
return iterator(begin_, index_begin_); }
335 reverse_iterator rbegin(
void) {
return reverse_iterator(end()); }
336 const_reverse_iterator rbegin(
void)
const
337 {
return const_reverse_iterator(end()); }
338 reverse_iterator rend(
void) {
return reverse_iterator(begin()); }
339 const_reverse_iterator rend(
void)
const
340 {
return const_reverse_iterator(begin()); }
342 reference front(
void) {
return *(begin_ + *index_begin_); }
343 const_reference front(
void)
const {
return *(begin_ + *index_begin_); }
344 reference back(
void) {
return *(--(end())); }
345 const_reference back(
void)
const {
return *(--(end())); }
346 void pop_front(
void) { ++index_begin_; }
350 const ITER_INDEX &ei)
351 : begin_(b), index_begin_(bi), index_end_(ei) {}
354 const_reference operator [](size_type ii)
const
355 {
return *(begin_ + index_begin_[ii]);}
356 reference operator [](size_type ii)
357 {
return *(begin_ + index_begin_[ii]); }
366 template<
typename ITER>
struct tab_ref_reg_spaced_iterator_ {
368 typedef typename std::iterator_traits<ITER>::value_type value_type;
369 typedef typename std::iterator_traits<ITER>::pointer pointer;
370 typedef typename std::iterator_traits<ITER>::reference reference;
371 typedef typename std::iterator_traits<ITER>::difference_type
373 typedef typename std::iterator_traits<ITER>::iterator_category
376 typedef tab_ref_reg_spaced_iterator_<ITER> iterator;
381 iterator operator ++(
int) { iterator tmp = *
this; i++;
return tmp; }
382 iterator operator --(
int) { iterator tmp = *
this; i--;
return tmp; }
383 iterator &operator ++() { i++;
return *
this; }
384 iterator &operator --() { i--;
return *
this; }
385 iterator &operator +=(difference_type ii) { i+=ii;
return *
this; }
386 iterator &operator -=(difference_type ii) { i-=ii;
return *
this; }
388 { iterator itt = *
this;
return (itt += ii); }
390 { iterator itt = *
this;
return (itt -= ii); }
391 difference_type
operator -(
const iterator &ii)
const
392 {
return (N ? (it - ii.it) / N : 0) + i - ii.i; }
394 reference operator *()
const {
return *(it + i*N); }
395 reference operator [](
size_type ii)
const {
return *(it + (i+ii)*N); }
397 bool operator ==(
const iterator &ii)
const
398 {
return (*
this - ii) == difference_type(0); }
399 bool operator !=(
const iterator &ii)
const
400 {
return (*
this - ii) != difference_type(0); }
401 bool operator < (
const iterator &ii)
const
402 {
return (*
this - ii) < difference_type(0); }
403 bool operator >=(
const iterator &ii)
const
404 {
return (*
this - ii) >= difference_type(0); }
405 bool operator > (
const iterator &ii)
const
406 {
return (*
this - ii) > difference_type(0); }
408 tab_ref_reg_spaced_iterator_(
void) {}
410 : it(iter), N(n), i(ii) { }
418 template<
typename ITER> tab_ref_reg_spaced_iterator_<ITER>
420 return tab_ref_reg_spaced_iterator_<ITER>(it, stride);
429 typedef typename std::iterator_traits<ITER>::value_type value_type;
430 typedef typename std::iterator_traits<ITER>::pointer pointer;
431 typedef typename std::iterator_traits<ITER>::pointer const_pointer;
432 typedef typename std::iterator_traits<ITER>::reference reference;
433 typedef typename std::iterator_traits<ITER>::reference const_reference;
434 typedef typename std::iterator_traits<ITER>::difference_type
436 typedef size_t size_type;
437 typedef tab_ref_reg_spaced_iterator_<ITER> iterator;
438 typedef iterator const_iterator;
439 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
440 typedef std::reverse_iterator<iterator> reverse_iterator;
449 bool empty(
void)
const {
return size_ == 0; }
450 size_type size(
void)
const {
return size_; }
452 iterator begin(
void) {
return iterator(begin_, N, 0); }
453 const_iterator begin(
void)
const {
return iterator(begin_, N, 0); }
454 iterator end(
void) {
return iterator(begin_, N, size_); }
455 const_iterator end(
void)
const {
return iterator(begin_, N, size_); }
456 reverse_iterator rbegin(
void) {
return reverse_iterator(end()); }
457 const_reverse_iterator rbegin(
void)
const
458 {
return const_reverse_iterator(end()); }
459 reverse_iterator rend(
void) {
return reverse_iterator(begin()); }
460 const_reverse_iterator rend(
void)
const
461 {
return const_reverse_iterator(begin()); }
463 reference front(
void) {
return *begin_; }
464 const_reference front(
void)
const {
return *begin_; }
465 reference back(
void) {
return *(begin_ + N * (size_-1)); }
466 const_reference back(
void)
const {
return *(begin_ + N * (size_-1)); }
467 void pop_front(
void) { begin_ += N; }
471 : begin_(b), N(n), size_(s) {}
474 const_reference operator [](size_type ii)
const
475 {
return *(begin_ + ii * N);}
476 reference operator [](size_type ii) {
return *(begin_ + ii * N); }
481 template<
typename ITER,
typename COND>
483 typedef typename std::iterator_traits<ITER>::value_type value_type;
484 typedef typename std::iterator_traits<ITER>::pointer pointer;
485 typedef typename std::iterator_traits<ITER>::reference reference;
486 typedef typename std::iterator_traits<ITER>::difference_type
488 typedef std::forward_iterator_tag iterator_category;
492 void forward(
void) {
while (!(cond)(*
this)) ITER::operator ++(); }
494 { ITER::operator ++(); forward();
return *
this; }
496 {
iterator tmp = *
this; ++(*this);
return tmp; }
500 : ITER(iter), cond(c) {}
517 typedef typename std::iterator_traits<ITER>::value_type value_type;
518 typedef typename std::iterator_traits<ITER>::pointer pointer;
519 typedef typename std::iterator_traits<ITER>::pointer const_pointer;
520 typedef typename std::iterator_traits<ITER>::reference reference;
521 typedef typename std::iterator_traits<ITER>::reference const_reference;
522 typedef size_t size_type;
527 {
iterator it(begin_, cond); it.forward();
return it; }
529 bool empty(
void)
const {
return begin_ == end_; }
531 value_type front(
void)
const {
return *begin(); }
532 void pop_front(
void) { ++begin_; begin_ = begin(); }
534 COND &condition(
void) {
return cond; }
535 const COND &condition(
void)
const {
return cond; }
539 : begin_(b), end_(e), cond(c) { begin_ = begin(); }
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
provide a "strided" view a of container
given a container X and a predicate P, provide pseudo-container Y of all elements of X such that P(X[...
Definition of basic exceptions.
tab_ref_index_ref_iterator_< ITER, ITER_INDEX > index_ref_iterator(ITER it, ITER_INDEX it_i)
convenience template function for quick obtention of a indexed iterator without having to specify its...
tab_ref_reg_spaced_iterator_< ITER > reg_spaced_iterator(ITER it, size_t stride)
convenience template function for quick obtention of a strided iterator without having to specify its...
rational_fraction< T > operator-(const polynomial< T > &P, const rational_fraction< T > &Q)
Subtract Q from P.
rational_fraction< T > operator+(const polynomial< T > &P, const rational_fraction< T > &Q)
Add Q to P.
size_t size_type
used as the common size type in the library
iterator over a gmm::tab_ref_index_ref<ITER,ITER_INDEX>
iterator over a tab_ref_with_selection