xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/include/ISet.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 ISet_INCLUDED
6 #define ISet_INCLUDED
7 
8 
9 #include <stddef.h>
10 #include "Vector.h"
11 #include "Boolean.h"
12 
13 #ifdef SP_NAMESPACE
14 namespace SP_NAMESPACE {
15 #endif
16 
17 template<class T> class ISetIter;
18 
19 template<class T>
20 struct ISetRange {
21   T min;
22   T max;
23 };
24 
25 template<class T>
26 class ISet {
27 public:
28   ISet();
29   ISet(const T *, size_t);
30   ~ISet();
31   Boolean contains(T) const;
32   void remove(T);
add(T x)33   void add(T x) { addRange(x, x); }
34   void addRange(T, T);
35 #if 0
36   void add(const ISet<T> &);
37 #endif
38   void check();
39   void operator+=(T x) { addRange(x, x); }
40   void clear();
isSingleton()41   Boolean isSingleton() const {
42     return r_.size() == 1 && r_[0].min == r_[0].max;
43   }
isEmpty()44   Boolean isEmpty() const { return r_.size() == 0; }
swap(ISet<T> & x)45   void swap(ISet<T> &x) { r_.swap(x.r_); }
46 friend class ISetIter<T>;
47 private:
48   Vector<ISetRange<T> > r_;
49 };
50 
51 #ifdef SP_NAMESPACE
52 }
53 #endif
54 
55 #endif /* not ISet_INCLUDED */
56 
57 #ifdef SP_DEFINE_TEMPLATES
58 #include "ISet.cxx"
59 #endif
60