xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/include/ISetIter.h (revision 0:68f95e015346)
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef ISetIter_INCLUDED
6 #define ISetIter_INCLUDED
7 
8 #include <stddef.h>
9 #include "ISet.h"
10 
11 #ifdef SP_NAMESPACE
12 namespace SP_NAMESPACE {
13 #endif
14 
15 template<class T>
16 class ISetIter {
17 public:
ISetIter(const ISet<T> & s)18   ISetIter(const ISet<T> &s) : p_(&s), i_(0) { }
19   // min and max are not changed if 0 is returned.
next(T & min,T & max)20   int next(T &min, T &max)
21   {
22     if (i_ < p_->r_.size()) {
23       min = p_->r_[i_].min;
24       max = p_->r_[i_].max;
25       i_++;
26       return 1;
27     }
28     else
29       return 0;
30   }
31 
32 private:
33   const ISet<T> *p_;
34   size_t i_;
35 };
36 
37 #ifdef SP_NAMESPACE
38 }
39 #endif
40 
41 #endif /* ISetIter_INCLUDED */
42