00001 00005 class SetOfNo(Type) : public virtual HandleId 00006 00007 { 00008 VecSort(Type) members; 00009 VecSimple(bool) marked; 00010 int n_members; 00011 int max_size; 00012 int chunk_size; 00013 int nrealloc; 00014 00015 bool newMember (); 00016 void allocate (); 00017 void allocateNewChunk(); 00018 00019 public: 00020 SetOfNo(Type) (int max_size); 00021 SetOfNo(Type) (); 00022 ~SetOfNo(Type) () {} 00023 00024 bool convert2vector (VecSimple(Type)& v); 00025 bool convert2vector (Ptv(Type)& v); 00026 00027 int getNoMembers () const { return n_members; } 00028 bool indexOk (int i) const; 00029 bool ok () const { return getbool(n_members>0); } 00030 00031 Type& getMember (int i); 00032 const Type& getMember (int i) const; 00033 00034 00035 Type& operator () (int i); 00036 const Type& operator () (int i) const; 00037 00038 bool operator == (Type value); 00039 bool operator != (Type value) { return notbool(operator==(value)); } 00040 00041 00042 00043 bool within (Type value, Type tolerance); 00044 bool within (Type value, Type tolerance, int& i); 00045 bool withinUnmarked (Type value, Type tolerance); 00046 bool withinUnmarked (Type value, Type tolerance, int& i); 00047 00048 void add (Type value); 00049 void mark (int i); 00050 bool isMarked (int i) const; 00051 void removeMarks (); 00052 void removeLast (); 00053 00054 void reset (); 00055 void remove () { reset(); } 00056 00057 bool empty() const { return getbool(getNoMembers()==0); } 00058 00059 void print 00060 ( 00061 Os os, 00062 int nmembers_between_each_newline = 6, 00063 bool unmarked_members_only = false 00064 ) const; 00065 00066 void scan 00067 ( 00068 Is is, 00069 char startmark = '\0', 00070 char sepmark = ' ', 00071 char endmark = ';' 00072 ); 00073 00074 friend Os& operator << (Os& os, const SetOfNo(Type) set); 00075 friend Is& operator >> (Is& is, SetOfNo(Type)& set); 00076 }; 00077 00078