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:
|