Cadabra
Computer algebra system for field theory problems
IndexIterator.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Storage.hh"
5 #include "Props.hh"
6 
7 namespace cadabra {
8 
15 
16  class index_iterator : public Ex::iterator_base {
17  public:
18  index_iterator(const Properties&);
20 
21  static index_iterator create(const Properties&, const iterator_base&);
22 
23  static index_iterator begin(const Properties&, const iterator_base&, int offset=0);
24  static index_iterator end(const Properties&, const iterator_base&);
25 
27  bool operator==(const index_iterator&) const;
28  bool operator!=(const index_iterator&) const;
31  index_iterator& operator+=(unsigned int);
32 
33  Ex::iterator halt, walk, roof;
34  private:
36 
37  bool is_index(Ex::iterator) const;
38  };
39 
40  struct iter_indices
41  {
42  struct iterator {
44  using difference_type = ptrdiff_t;
46  using const_reference = const value_type&;
47  using pointer = value_type*;
48  using const_pointer = const value_type*;
49  using iterator_category = std::input_iterator_tag;
50 
52 
53  bool operator == (const iterator& other) { return it == other.it; }
54  bool operator != (const iterator& other) { return !(*this == other); }
55  reference operator* () { return it; }
56  pointer operator-> () { return ⁢ }
57  reference operator ++ () { return ++it; }
58  value_type operator ++ (int) { return it++; }
59 
60 
62  };
63 
64  iter_indices(const Properties& properties, Ex::iterator it)
65  : it(it)
66  , properties(properties) { }
67 
69  iterator begin(int offset) { return index_iterator::begin(properties, it, offset); }
71  size_t size() { return std::distance(begin(), end()); }
72 
73  private:
74  Ex::iterator it;
76  };
77  //size_t number_of_indices(const Properties&, Ex::iterator);
78  }
cadabra::iter_indices::iterator::it
index_iterator it
Definition: IndexIterator.hh:61
cadabra::iter_indices::begin
iterator begin(int offset)
Definition: IndexIterator.hh:69
cadabra::iter_indices::size
size_t size()
Definition: IndexIterator.hh:71
cadabra::iter_indices::iterator::operator->
pointer operator->()
Definition: IndexIterator.hh:56
cadabra::index_iterator
Definition: IndexIterator.hh:16
cadabra::index_iterator::properties
const Properties * properties
Definition: IndexIterator.hh:35
cadabra::index_iterator::index_iterator
index_iterator(const Properties &)
Definition: IndexIterator.cc:7
cadabra::iter_indices::iterator
Definition: IndexIterator.hh:42
cadabra::index_iterator::operator==
bool operator==(const index_iterator &) const
Definition: IndexIterator.cc:37
cadabra::index_iterator::create
static index_iterator create(const Properties &, const iterator_base &)
Definition: IndexIterator.cc:12
cadabra::iter_indices::iterator::operator*
reference operator*()
Definition: IndexIterator.hh:55
cadabra::index_iterator::end
static index_iterator end(const Properties &, const iterator_base &)
Definition: IndexIterator.cc:130
cadabra::index_iterator::walk
Ex::iterator walk
Definition: IndexIterator.hh:33
cadabra::Properties
Definition: Props.hh:233
cadabra::iter_indices::iterator::iterator
iterator(index_iterator it)
Definition: IndexIterator.hh:51
cadabra::index_iterator::operator=
index_iterator & operator=(const index_iterator &)
Definition: IndexIterator.cc:138
cadabra::iter_indices::iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: IndexIterator.hh:49
cadabra::iter_indices
Definition: IndexIterator.hh:40
cadabra::iter_indices::begin
iterator begin()
Definition: IndexIterator.hh:68
Storage.hh
cadabra::index_iterator::halt
Ex::iterator halt
Definition: IndexIterator.hh:33
cadabra::index_iterator::operator++
index_iterator & operator++()
Definition: IndexIterator.cc:84
cadabra::iter_indices::iter_indices
iter_indices(const Properties &properties, Ex::iterator it)
Definition: IndexIterator.hh:64
cadabra::iter_indices::it
Ex::iterator it
Definition: IndexIterator.hh:74
cadabra::iter_indices::iterator::operator++
reference operator++()
Definition: IndexIterator.hh:57
cadabra::index_iterator::operator+=
index_iterator & operator+=(unsigned int)
Definition: IndexIterator.cc:74
cadabra::index_iterator::operator!=
bool operator!=(const index_iterator &) const
Definition: IndexIterator.cc:31
Props.hh
cadabra::index_iterator::begin
static index_iterator begin(const Properties &, const iterator_base &, int offset=0)
Definition: IndexIterator.cc:122
cadabra::iter_indices::iterator::operator==
bool operator==(const iterator &other)
Definition: IndexIterator.hh:53
cadabra::iter_indices::iterator::operator!=
bool operator!=(const iterator &other)
Definition: IndexIterator.hh:54
cadabra
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
cadabra::index_iterator::roof
Ex::iterator roof
Definition: IndexIterator.hh:33
cadabra::iter_indices::iterator::difference_type
ptrdiff_t difference_type
Definition: IndexIterator.hh:44
cadabra::iter_indices::properties
const Properties & properties
Definition: IndexIterator.hh:75
cadabra::iter_indices::end
iterator end()
Definition: IndexIterator.hh:70
cadabra::index_iterator::is_index
bool is_index(Ex::iterator) const