00001 /* 00002 * See the dyninst/COPYRIGHT file for copyright information. 00003 * 00004 * We provide the Paradyn Tools (below described as "Paradyn") 00005 * on an AS IS basis, and do not warrant its validity or performance. 00006 * We reserve the right to update, modify, or discontinue this 00007 * software at any time. We shall have no obligation to supply such 00008 * updates or modifications or any other form of support to you. 00009 * 00010 * By your use of Paradyn, you understand and agree that we (or any 00011 * other person or entity with proprietary rights in Paradyn) are 00012 * under no obligation to provide either maintenance services, 00013 * update services, notices of latent defects, or correction of 00014 * defects for Paradyn. 00015 * 00016 * This library is free software; you can redistribute it and/or 00017 * modify it under the terms of the GNU Lesser General Public 00018 * License as published by the Free Software Foundation; either 00019 * version 2.1 of the License, or (at your option) any later version. 00020 * 00021 * This library is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 * Lesser General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU Lesser General Public 00027 * License along with this library; if not, write to the Free Software 00028 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00029 */ 00030 00031 // vectorSet.h 00032 // A container class for a set of objects providing just a few operations 00033 // (but doing so _very_ efficiently, in space and time): 00034 // 1) add an item 00035 // 2) remove an arbitrary item from the set and return its contents 00036 // 3) peek at individual items in the set by their index (0 thru size-1) 00037 // 4) remove an item by its index 00038 00039 #ifndef _VECTOR_SET_H_ 00040 #define _VECTOR_SET_H_ 00041 00042 #ifdef external_templates 00043 #pragma interface 00044 #endif 00045 00046 #if defined(__XLC__) || defined(__xlC__) 00047 #pragma implementation("../src/vectorSet.C") 00048 #endif 00049 00050 00051 #include "common/h/Vector.h" 00052 00053 template <class T> 00054 class DLLEXPORT vectorSet { 00055 private: 00056 pdvector<T> data; 00057 00058 public: 00059 vectorSet() {} // empty set 00060 vectorSet(const vectorSet &src) : data(src.data) {} 00061 ~vectorSet() {} 00062 00063 vectorSet &operator=(const vectorSet &src) { 00064 data = src.data; 00065 return *this; 00066 } 00067 00068 bool empty() const {return data.size() == 0;} 00069 unsigned size() const {return data.size();} 00070 00071 const T &operator[](unsigned index) const { 00072 return data[index]; 00073 } 00074 00075 T &operator[](unsigned index) { 00076 return data[index]; 00077 } 00078 00079 T removeByIndex(unsigned index); 00080 T removeOne() { 00081 return removeByIndex(0); 00082 } 00083 00084 vectorSet &operator+=(const T &item) { 00085 data.push_back(item); 00086 return *this; 00087 } 00088 }; 00089 00090 00091 #endif 00092
1.6.1