Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ID.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.2 $
00022 // $Date: 2000/12/12 07:14:39 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/matrix/ID.h,v $
00024                                                                         
00025                                                                         
00026 // File: ~/matrix/ID.h
00027 //
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for ID.
00033 // ID is a concrete class implementing the integer array abstraction.
00034 // ID objects are Vectors of integers which only need a few
00035 // operators defined on them.
00036 //
00037 // What: "@(#) ID.h, revA"
00038 
00039 
00040 #ifndef ID_h
00041 #define ID_h
00042 
00043 #include <iostream.h>
00044 #include <G3Globals.h>
00045 
00065 class ID
00066 {
00067   public:
00069     ID();
00074     ID(int);
00075 
00083     ID(int size, int arraySize);    
00084 
00093     ID(const ID &);    
00094 
00102     ~ID();
00103 
00104  
00106     int Size(void) const;
00112     void Zero(void);
00113 
00114     
00116     inline int &operator()(int x);
00122     inline int operator()(int x) const;
00123 
00136     int &operator[](int);         
00137 
00138     
00146     ID &operator=(const ID  &V);
00147 
00148     
00150     int getLocation(int value) const;
00151 
00153     int removeValue(int value);
00154 
00156     friend ostream &operator<<(ostream &s, const ID &V);
00158     friend istream &operator>>(istream &s, ID &V);    
00159 
00161     friend #include <UDP_Socket.h>
00162     friend #include <TCP_Socket.h>
00163     friend #include <TCP_SocketNoDelay.h>
00164     friend #include <MPI_Channel.h>
00165     
00166   private:
00167     static int ID_NOT_VALID_ENTRY;
00169     int sz;
00171     int *data;
00173     int arraySize;
00174 };
00175 
00176 
00178 inline int 
00179 ID::Size(void) const {return sz;}
00180 
00182 inline int &
00183 ID::operator()(int x) 
00184 {
00185 #ifdef _G3DEBUG
00186   // check if it is inside range [0,sz-1]
00187   if (x < 0 || x >= sz) {
00188       g3ErrorHandler->warning("ID::(loc) - loc %d outside range [0, %d]\n",x,sz-1);
00189       return ID_NOT_VALID_ENTRY;
00190   }
00191 #endif
00192 
00193   return data[x];
00194 }
00195 
00197 inline int
00198 ID::operator()(int x) const 
00199 {
00200 #ifdef _G3DEBUG
00201   // check if it is inside range [0,sz-1]
00202   if (x < 0 || x >= sz) {
00203       g3ErrorHandler->warning("ID::(loc) - loc %d outside range [0, %d]\n",x,sz-1);
00204       return ID_NOT_VALID_ENTRY;
00205   }
00206 #endif
00207 
00208   return data[x];
00209 }
00210 
00211 #endif
00212 
00213 
Copyright Contact Us