00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ID_h
00038 #define ID_h
00039
00040 #include <OPS_Globals.h>
00041
00042 class ID
00043 {
00044 public:
00045
00046 ID();
00047 ID(int);
00048 ID(int size, int arraySize);
00049 ID(int *data, int size, bool cleanIt = false);
00050 ID(const ID &);
00051 ~ID();
00052
00053
00054 int Size(void) const;
00055 void Zero(void);
00056 int setData(int *newData, int size, bool cleanIt = false);
00057 int resize(int newSize);
00058
00059
00060 inline int &operator()(int x);
00061 inline int operator()(int x) const;
00062 int &operator[](int);
00063
00064 ID &operator=(const ID &V);
00065
00066 int insert(int value);
00067 int getLocation(int value) const;
00068 int getLocationOrdered(int value) const;
00069 int removeValue(int value);
00070
00071 friend OPS_Stream &operator<<(OPS_Stream &s, const ID &V);
00072
00073
00074 friend class UDP_Socket;
00075 friend class TCP_Socket;
00076 friend class TCP_SocketNoDelay;
00077 friend class MPI_Channel;
00078 friend class MySqlDatastore;
00079 friend class BerkeleyDbDatastore;
00080
00081 private:
00082 static int ID_NOT_VALID_ENTRY;
00083 int sz;
00084 int *data;
00085 int arraySize;
00086 int fromFree;
00087 };
00088
00089
00090 inline int
00091 ID::Size(void) const {return sz;}
00092
00093 inline int &
00094 ID::operator()(int x)
00095 {
00096 #ifdef _G3DEBUG
00097
00098 if (x < 0 || x >= sz) {
00099 opserr << "ID::(loc) - loc " << x << " outside range 0 - " << sz-1 << endln;
00100 return ID_NOT_VALID_ENTRY;
00101 }
00102 #endif
00103
00104
00105 return data[x];
00106 }
00107
00108 inline int
00109 ID::operator()(int x) const
00110 {
00111 #ifdef _G3DEBUG
00112
00113 if (x < 0 || x >= sz) {
00114 opserr << "ID::(loc) - loc " << x << " outside range 0 - " << sz-1 << endln;
00115 return ID_NOT_VALID_ENTRY;
00116 }
00117 #endif
00118
00119 return data[x];
00120 }
00121
00122 #endif
00123
00124