File: index.hpp

package info (click to toggle)
macaulay2 1.21%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 133,096 kB
  • sloc: cpp: 110,377; ansic: 16,306; javascript: 4,193; makefile: 3,821; sh: 3,580; lisp: 764; yacc: 590; xml: 177; python: 140; perl: 114; lex: 65; awk: 3
file content (53 lines) | stat: -rw-r--r-- 938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// (c) 1994  Michael E. Stillman

#ifndef _Index_hh_
#define _Index_hh_

template <class T>
class Index
{
  void *ind;

  const T *collection;

 public:
  Index() : ind(nullptr), collection(nullptr) {}
  Index(void *i, const T *c) : ind(i), collection(c) {}
  Index(const Index<T> &i) = default; 
  Index<T>& operator=(const Index<T> &i) = default;
  Index<T> operator++()
  {
    ind = collection->next(ind);
    return *this;
  }

  Index<T> operator--()
  {
    ind = collection->prev(ind);
    return *this;
  }

  Index<T> operator++(int)
  {
    Index<T> tmp = *this;
    ind = collection->next(ind);
    return tmp;
  }

  Index<T> operator--(int)
  {
    Index<T> tmp = *this;
    ind = collection->prev(ind);
    return tmp;
  }

  int valid() { return collection->valid(ind); }
  void *val() { return ind; }
};

#endif

// Local Variables:
// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
// indent-tabs-mode: nil
// End: