Changeset 9952bd in git for libpolys/coeffs/Enumerator.h
- Timestamp:
- Sep 10, 2012, 2:13:09 PM (11 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 8d341e5425f8b7b26cdf77eec4ee78cbbb121c5c
- Parents:
- 6dffa9e5b66ac5a81df2b68ff1c38dafc918b1f9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/Enumerator.h
r6dffa9 r9952bd 22 22 /** @class IBaseEnumerator 23 23 * 24 * Base enumerator interface for simple iteration over a generic non-empty collection. 25 * 26 * Abstract API of enumerators for non-empty enumerable collections of standalone 27 * objects. Inspired by IEnumerator from C#. Usage parrten can be as 28 * follows: 24 * Base enumerator interface for simple iteration over a generic collection. 25 * 26 * Abstract API of enumerators for enumerable collections of standalone objects. 27 * Just like IEnumerator from C#. Usage pattern can be as follows: 29 28 * 30 29 * @code 31 * IBaseEnumerator itr = ...; 32 * itr.Reset(); // goes to the first element (must exist) 33 * do 30 * IBaseEnumerator& itr = ...; 31 * itr.Reset(); // goes to the "-1" element 32 * // NOTE: itr is not useable here! 33 * while( itr.MoveNext() ) 34 34 * { 35 35 * do something custom with itr... 36 36 * } 37 * while( itr.MoveNext() )38 37 * @endcode 39 38 * 40 * Note that the first element must exist and available directly after Reset() call.39 * Note that the Reset() 41 40 * 42 41 * @sa IEnumerator … … 51 50 virtual bool MoveNext() = 0; 52 51 53 /// Sets the enumerator to its initial position, which is at the first element in the collection. 52 /// Sets the enumerator to its initial position: -1, 53 /// which is before the first element in the collection. 54 54 virtual void Reset() = 0; 55 // virtual ~IEnumerator() {} // TODO: needed? 55 56 virtual ~IBaseEnumerator() {} // TODO: needed? 57 58 private: 59 IBaseEnumerator(const IBaseEnumerator&); 60 void operator=(const IBaseEnumerator&); 61 62 protected: 63 IBaseEnumerator(){} 64 65 /// Current position is inside the collection (not -1 or past the end) 66 virtual bool IsValid() const = 0; 56 67 }; 57 68 … … 78 89 /// Gets the current element in the collection (read only). 79 90 virtual const_reference Current() const = 0; 91 92 virtual ~IAccessor() {} // TODO: needed? 93 80 94 }; 81 95 82 96 /** @class IEnumerator 83 97 * 84 * Templated enumerator interface for simple iteration over a generic non-emptycollection of T's.85 * 86 * Abstract API of enumerators for non-emptyenumerable collections of standalone87 * objects . Inspired by IEnumerator from C#. Usage parrten can be as98 * Templated enumerator interface for simple iteration over a generic collection of T's. 99 * 100 * Abstract API of enumerators for generic enumerable collections of standalone 101 * objects of type T. Inspired by IEnumerator from C#. Usage parrten can be as 88 102 * follows: 89 103 * 90 104 * @code 91 * IEnumerator<T> itr = ...; 92 * itr.Reset(); // goes to the first element (must exist) 93 * do 105 * IEnumerator<T>& itr = ...; 106 * 107 * itr.Reset(); // goes before the first element, thus no itr.Current() is available here! 108 * 109 * while( itr.MoveNext() ) 94 110 * { 95 111 * use/change itr.Current()... 96 112 * } 97 * while( itr.MoveNext() )98 113 * @endcode 99 114 *
Note: See TracChangeset
for help on using the changeset viewer.