00001 /* 00002 ***************************************************************** 00003 ***************************************************************** 00004 ******* ******** 00005 ******* (C) Copyright 1989-2007 by Tecplot Inc. ******** 00006 ******* All Rights Reserved. ******** 00007 ******* ******** 00008 ***************************************************************** 00009 ***************************************************************** 00010 */ 00011 #ifndef TECPLOT_TOOLBOX_SET_H 00012 #define TECPLOT_TOOLBOX_SET_H 00013 00014 #if defined MSWIN 00015 #pragma once 00016 #endif 00017 00018 #include "tptoolbox.h" 00019 #include "OutOfMemoryException.h" 00020 #include "InvalidArgumentException.h" 00021 #include <string> 00022 #include <set> 00023 00024 namespace tecplot { namespace toolbox { 00025 00032 class TPTOOLBOX_DLLAPI Set 00033 { 00034 public: 00041 explicit Set() throw (OutOfMemoryException); 00042 00052 explicit Set(SetIndex_t member) throw (OutOfMemoryException); 00053 00078 explicit Set(std::string strValue) throw (OutOfMemoryException, InvalidArgumentException); 00079 00080 00097 explicit Set(std::set<int> const& stdSet) throw (OutOfMemoryException, InvalidArgumentException); 00098 00120 explicit Set(Set_pa set) throw (OutOfMemoryException); 00121 00131 Set(const Set& set) throw (OutOfMemoryException); 00132 00133 virtual ~Set(); 00134 00148 virtual Boolean_t operator==(const Set& rhs) const; 00149 00162 virtual Boolean_t operator!=(const Set& rhs) const; 00163 00164 00174 virtual Set& operator=(SetIndex_t rhs) throw (OutOfMemoryException); 00175 00185 virtual Set& operator=(const Set& rhs) throw (OutOfMemoryException); 00186 00204 virtual Set& operator=(const std::string rhs) throw (OutOfMemoryException, InvalidArgumentException); 00205 00215 virtual Set& operator+=(SetIndex_t rhs) throw (OutOfMemoryException); 00216 00226 virtual Set& operator+=(const Set& rhs) throw (OutOfMemoryException); 00227 00245 virtual Set& operator+=(const std::string rhs) throw (OutOfMemoryException, InvalidArgumentException); 00246 00253 virtual Set& operator-=(SetIndex_t member); 00254 00261 virtual Set& operator-=(const Set& rhs); 00262 00281 virtual Set& operator-=(const std::string rhs) throw (OutOfMemoryException, InvalidArgumentException); 00282 00292 virtual void add(SetIndex_t member) throw (OutOfMemoryException); 00293 00303 virtual void add(const Set& set) throw (OutOfMemoryException); 00304 00311 virtual void remove(SetIndex_t member); 00312 00319 virtual void remove(const Set& set); 00320 00324 virtual void clear(); 00325 00335 virtual void assign(const Set& set) throw (OutOfMemoryException); 00336 00362 virtual void assign(std::string strValue) throw (OutOfMemoryException, InvalidArgumentException); 00363 00373 virtual void toStdSet(std::set<int>& stdSet); 00374 00385 virtual std::string toString() const; 00386 00395 virtual const Set_pa getRef() const; 00396 00407 virtual SetIndex_t get(SetIndex_t position) const; 00408 00415 virtual SetIndex_t size() const; 00416 00432 virtual SetIndex_t getNext(SetIndex_t member) const; 00433 00444 virtual SetIndex_t getPosition(SetIndex_t member) const; 00445 00462 static Set intersection(const Set& set1, const Set& set2) throw (OutOfMemoryException); 00463 00470 virtual Boolean_t isEmpty() const; 00471 00482 virtual Boolean_t isEqual(const Set& other) const; 00483 00493 virtual Boolean_t isMember(SetIndex_t member) const; 00494 00501 virtual Boolean_t isValidMember(SetIndex_t member) const 00502 { return member >= 1; } 00503 00510 virtual Boolean_t isValidPosition(SetIndex_t position) const 00511 { return position >= 1; } 00512 00513 private: 00516 void alloc() throw (OutOfMemoryException); 00519 void dealloc(); 00522 void copy(Set_pa set) throw (OutOfMemoryException); 00523 00524 Set_pa m_set; 00525 }; 00526 00527 00528 00529 00530 }} 00531 00532 #endif
1.5.5