From 2fce43d484e4148ae858f410d51dcd9951d34374 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Sun, 18 Sep 2016 15:45:13 +0000 Subject: remove include & rename --- omegalib/omega/include/basic/Section.h | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 omegalib/omega/include/basic/Section.h (limited to 'omegalib/omega/include/basic/Section.h') diff --git a/omegalib/omega/include/basic/Section.h b/omegalib/omega/include/basic/Section.h new file mode 100644 index 0000000..60821d1 --- /dev/null +++ b/omegalib/omega/include/basic/Section.h @@ -0,0 +1,63 @@ +#if ! defined _Section_h +#define _Section_h 1 +/* + Section of an existing collection viewed as a collection + */ + +#include + +namespace omega { + +template class Section_Iterator; + +template class Section : public Sequence { +public: + Section(Sequence *, int start, int length); + + Iterator *new_iterator(); + + const T &operator[](int) const; + T &operator[](int); + + int index(const T &) const; + int size() const; + + friend class Section_Iterator; + +private: + Sequence *it; + int _start, _length; +}; + +template class Section_Iterator : public Iterator { +public: + Section_Iterator(Section &sec); + virtual ~Section_Iterator() { delete it; } + + const T & operator*() const { return *(*it); } + T & operator*() { return *(*it); } + + void operator++(int); + void operator++(); + + bool live() const; + Iterator *new_copy() const; + +private: + Section_Iterator(const Section_Iterator &si); + Iterator *it; + int remaining; +}; + +} // namespace + +#if ! defined DONT_INCLUDE_TEMPLATE_CODE +#include +#endif + +#define instantiate_Section(T) template class Section; \ + template class Section_Iterator; \ + instantiate_Sequence(T) +#define instantiate_Section_Iterator(T) instantiate_Section(T) + +#endif -- cgit v1.2.3-70-g09d2