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) {}
225 template<
typename ITER,
typename ITER_INDEX>
228 typedef typename std::iterator_traits<ITER>::value_type value_type;
229 typedef typename std::iterator_traits<ITER>::pointer pointer;
230 typedef typename std::iterator_traits<ITER>::reference reference;
231 typedef typename std::iterator_traits<ITER>::difference_type
233 typedef std::random_access_iterator_tag iterator_category;
238 ITER_INDEX iter_index;
240 iterator operator ++(
int)
241 { iterator tmp = *
this; ++iter_index;
return tmp; }
242 iterator operator --(
int)
243 { iterator tmp = *
this; --iter_index;
return tmp; }
244 iterator &operator ++() { ++iter_index;
return *
this; }
245 iterator &operator --() { --iter_index;
return *
this; }
246 iterator &operator +=(difference_type i)
247 { iter_index += i;
return *
this; }
248 iterator &operator -=(difference_type i)
249 { iter_index -= i;
return *
this; }
251 { iterator it = *
this;
return (it += i); }
253 { iterator it = *
this;
return (it -= i); }
254 difference_type
operator -(
const iterator &i)
const 255 {
return iter_index - i.iter_index; }
257 reference operator *()
const 258 {
return *(piter + *iter_index); }
259 reference operator [](size_type ii)
const 260 {
return *(piter + *(iter_index+ii)); }
262 bool operator ==(
const iterator &i)
const 263 {
return ((piter) == ((i.piter)) && iter_index == i.iter_index); }
264 bool operator !=(
const iterator &i)
const {
return !(i == *
this); }
265 bool operator < (
const iterator &i)
const 266 {
return ((piter) == ((i.piter)) && iter_index < i.iter_index); }
270 const ITER_INDEX &dnas_iter)
271 : piter(iter), iter_index(dnas_iter) {}
279 template<
typename ITER,
typename ITER_INDEX>
292 typedef std::iterator_traits<ITER> traits_type;
293 typedef typename traits_type::value_type value_type;
294 typedef typename traits_type::pointer pointer;
295 typedef typename traits_type::pointer const_pointer;
296 typedef typename traits_type::reference reference;
297 typedef typename traits_type::reference const_reference;
298 typedef typename traits_type::difference_type difference_type;
301 typedef iterator const_iterator;
302 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
303 typedef std::reverse_iterator<iterator> reverse_iterator;
308 ITER_INDEX index_begin_, index_end_;
312 bool empty(
void)
const {
return index_begin_ == index_end_; }
313 size_type size(
void)
const {
return index_end_ - index_begin_; }
315 iterator begin(
void) {
return iterator(begin_, index_begin_); }
316 const_iterator begin(
void)
const 317 {
return iterator(begin_, index_begin_); }
318 iterator end(
void) {
return iterator(begin_, index_end_); }
319 const_iterator end(
void)
const {
return iterator(begin_, index_end_); }
320 reverse_iterator rbegin(
void) {
return reverse_iterator(end()); }
321 const_reverse_iterator rbegin(
void)
const 322 {
return const_reverse_iterator(end()); }
323 reverse_iterator rend(
void) {
return reverse_iterator(begin()); }
324 const_reverse_iterator rend(
void)
const 325 {
return const_reverse_iterator(begin()); }
327 reference front(
void) {
return *(begin_ + *index_begin_); }
328 const_reference front(
void)
const {
return *(begin_ + *index_begin_); }
329 reference back(
void) {
return *(--(end())); }
330 const_reference back(
void)
const {
return *(--(end())); }
331 void pop_front(
void) { ++index_begin_; }
335 const ITER_INDEX &ei)
336 : begin_(b), index_begin_(bi), index_end_(ei) {}
339 const_reference operator [](size_type ii)
const 340 {
return *(begin_ + index_begin_[ii]);}
341 reference operator [](size_type ii)
342 {
return *(begin_ + index_begin_[ii]); }
351 template<
typename ITER>
struct tab_ref_reg_spaced_iterator_ {
353 typedef typename std::iterator_traits<ITER>::value_type value_type;
354 typedef typename std::iterator_traits<ITER>::pointer pointer;
355 typedef typename std::iterator_traits<ITER>::reference reference;
356 typedef typename std::iterator_traits<ITER>::difference_type
358 typedef typename std::iterator_traits<ITER>::iterator_category
361 typedef tab_ref_reg_spaced_iterator_<ITER> iterator;
366 iterator operator ++(
int) { iterator tmp = *
this; i++;
return tmp; }
367 iterator operator --(
int) { iterator tmp = *
this; i--;
return tmp; }
368 iterator &operator ++() { i++;
return *
this; }
369 iterator &operator --() { i--;
return *
this; }
370 iterator &operator +=(difference_type ii) { i+=ii;
return *
this; }
371 iterator &operator -=(difference_type ii) { i-=ii;
return *
this; }
373 { iterator itt = *
this;
return (itt += ii); }
375 { iterator itt = *
this;
return (itt -= ii); }
376 difference_type
operator -(
const iterator &ii)
const 377 {
return (N ? (it - ii.it) / N : 0) + i - ii.i; }
379 reference operator *()
const {
return *(it + i*N); }
380 reference operator [](size_type ii)
const {
return *(it + (i+ii)*N); }
382 bool operator ==(
const iterator &ii)
const 383 {
return (*
this - ii) == difference_type(0); }
384 bool operator !=(
const iterator &ii)
const 385 {
return (*
this - ii) != difference_type(0); }
386 bool operator < (
const iterator &ii)
const 387 {
return (*
this - ii) < difference_type(0); }
389 tab_ref_reg_spaced_iterator_(
void) {}
390 tab_ref_reg_spaced_iterator_(
const ITER &iter, size_type n, size_type ii)
391 : it(iter), N(n), i(ii) { }
399 template<
typename ITER> tab_ref_reg_spaced_iterator_<ITER>
401 return tab_ref_reg_spaced_iterator_<ITER>(it, stride);
410 typedef typename std::iterator_traits<ITER>::value_type value_type;
411 typedef typename std::iterator_traits<ITER>::pointer pointer;
412 typedef typename std::iterator_traits<ITER>::pointer const_pointer;
413 typedef typename std::iterator_traits<ITER>::reference reference;
414 typedef typename std::iterator_traits<ITER>::reference const_reference;
415 typedef typename std::iterator_traits<ITER>::difference_type
418 typedef tab_ref_reg_spaced_iterator_<ITER> iterator;
419 typedef iterator const_iterator;
420 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
421 typedef std::reverse_iterator<iterator> reverse_iterator;
430 bool empty(
void)
const {
return size_ == 0; }
431 size_type size(
void)
const {
return size_; }
433 iterator begin(
void) {
return iterator(begin_, N, 0); }
434 const_iterator begin(
void)
const {
return iterator(begin_, N, 0); }
435 iterator end(
void) {
return iterator(begin_, N, size_); }
436 const_iterator end(
void)
const {
return iterator(begin_, N, size_); }
437 reverse_iterator rbegin(
void) {
return reverse_iterator(end()); }
438 const_reverse_iterator rbegin(
void)
const 439 {
return const_reverse_iterator(end()); }
440 reverse_iterator rend(
void) {
return reverse_iterator(begin()); }
441 const_reverse_iterator rend(
void)
const 442 {
return const_reverse_iterator(begin()); }
444 reference front(
void) {
return *begin_; }
445 const_reference front(
void)
const {
return *begin_; }
446 reference back(
void) {
return *(begin_ + N * (size_-1)); }
447 const_reference back(
void)
const {
return *(begin_ + N * (size_-1)); }
448 void pop_front(
void) { begin_ += N; }
452 : begin_(b), N(n), size_(s) {}
455 const_reference operator [](size_type ii)
const 456 {
return *(begin_ + ii * N);}
457 reference operator [](size_type ii) {
return *(begin_ + ii * N); }
462 template<
typename ITER,
typename COND>
464 typedef typename std::iterator_traits<ITER>::value_type value_type;
465 typedef typename std::iterator_traits<ITER>::pointer pointer;
466 typedef typename std::iterator_traits<ITER>::reference reference;
467 typedef typename std::iterator_traits<ITER>::difference_type
469 typedef std::forward_iterator_tag iterator_category;
473 void forward(
void) {
while (!(cond)(*
this)) ITER::operator ++(); }
474 iterator &operator ++()
475 { ITER::operator ++(); forward();
return *
this; }
476 iterator operator ++(
int)
477 { iterator tmp = *
this; ++(*this);
return tmp; }
481 : ITER(iter), cond(c) {}
498 typedef typename std::iterator_traits<ITER>::value_type value_type;
499 typedef typename std::iterator_traits<ITER>::pointer pointer;
500 typedef typename std::iterator_traits<ITER>::pointer const_pointer;
501 typedef typename std::iterator_traits<ITER>::reference reference;
502 typedef typename std::iterator_traits<ITER>::reference const_reference;
505 typedef iterator const_iterator;
507 iterator begin(
void)
const 508 { iterator it(begin_, cond); it.forward();
return it; }
509 iterator end(
void)
const {
return iterator(end_, cond); }
510 bool empty(
void)
const {
return begin_ == end_; }
512 value_type front(
void)
const {
return *begin(); }
513 void pop_front(
void) { ++begin_; begin_ = begin(); }
515 COND &condition(
void) {
return cond; }
516 const COND &condition(
void)
const {
return cond; }
520 : 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...
iterator over a gmm::tab_ref_index_ref<ITER,ITER_INDEX>
rational_fraction< T > operator+(const polynomial< T > &P, const rational_fraction< T > &Q)
Add Q to P.
rational_fraction< T > operator-(const polynomial< T > &P, const rational_fraction< T > &Q)
Subtract Q from P.
size_t size_type
used as the common size type in the library
Definition of basic exceptions.
iterator over a tab_ref_with_selection
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...
provide a "strided" view a of container
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...
given a container X and a predicate P, provide pseudo-container Y of all elements of X such that P(X[...