Changeset 1011 for trunk/src/core
- Timestamp:
- Jun 4, 2008, 11:21:15 AM (16 years ago)
- Location:
- trunk/src/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpBindingsDict.cc
r569 r1011 5 5 * ====================================================================== 6 6 * AUTHOR: Derrick S. Kearney, Purdue University 7 * Copyright (c) 2004-200 5Purdue Research Foundation7 * Copyright (c) 2004-2008 Purdue Research Foundation 8 8 * 9 9 * See the file "license.terms" for information on usage and … … 44 44 dictKey = ObjDict_Lib.size() + 1; 45 45 } 46 ObjDict_Lib.set(dictKey,objectName, NULL,&newEntry); 46 long int dictKey_long = dictKey; 47 ObjDict_Lib.set(dictKey_long,objectName,NULL,&newEntry); 47 48 retVal = dictKey; 48 49 } … … 70 71 RpDictEntry DICT_TEMPLATE_L* nullEntry = &(ObjDict_Lib.getNullEntry()); 71 72 72 libEntry = &(ObjDict_Lib.find(objKey)); 73 long int objKey_long = objKey; 74 libEntry = &(ObjDict_Lib.find(objKey_long)); 73 75 74 76 … … 138 140 // no error checking to make sure it was successful in entering 139 141 // the new entry. 140 ObjDictUnits.set(dictNextKey,objectName, NULL, &newEntry); 142 long int dictNextKey_long = dictNextKey; 143 ObjDictUnits.set(dictNextKey_long,objectName, NULL, &newEntry); 141 144 retVal = dictNextKey; 142 145 } … … 160 163 getObject_UnitsStr(int objKey) { 161 164 162 /*163 std::string basisName = *(ObjDictUnits.find(objKey).getValue());164 165 if (basisName == *(ObjDictUnits.getNullEntry().getValue())) {166 // basisName = "";167 return NULL;168 }169 170 return RpUnits::find(basisName);171 */172 173 165 RpDictEntry DICT_TEMPLATE_U* unitEntry = &(ObjDictUnits.getNullEntry()); 174 166 RpDictEntry DICT_TEMPLATE_U* nullEntry = &(ObjDictUnits.getNullEntry()); 175 167 176 unitEntry = &(ObjDictUnits.find(objKey)); 168 long int objKey_long = objKey; 169 unitEntry = &(ObjDictUnits.find(objKey_long)); 177 170 178 171 … … 199 192 200 193 RpDictEntry DICT_TEMPLATE_U *hPtr; 201 // RpDictIterator DICT_TEMPLATE iter(fortObjDict_Lib);202 194 // should rp_quit clean up the dict or some function in RpBindingsCommon.h 203 195 RpDictIterator DICT_TEMPLATE_U iter(ObjDictUnits); … … 206 198 207 199 while (hPtr) { 208 // Py_DECREF(*(hPtr->getValue()));209 200 hPtr->erase(); 210 201 hPtr = iter.next(); 211 202 } 212 203 213 // if (fortObjDict_Lib.size()) {214 204 if (ObjDictUnits.size()) { 215 205 // probably want to change the warning sometime 216 206 // printf("\nWARNING: internal dictionary is not empty..deleting\n"); 217 207 } 218 219 } 208 } -
trunk/src/core/RpBindingsDict.h
r511 r1011 28 28 */ 29 29 30 #define DICT_TEMPLATE_L < int,RpLibrary*>31 #define DICT_TEMPLATE_U < int,std::string>30 #define DICT_TEMPLATE_L <long,RpLibrary*> 31 #define DICT_TEMPLATE_U <long,std::string> 32 32 33 33 // global declaration of library and units dictionaries -
trunk/src/core/RpDict.h
r962 r1011 4 4 * 5 5 * AUTHOR: Derrick Kearney, Purdue University 6 * Copyright (c) 2004-200 5Purdue Research Foundation6 * Copyright (c) 2004-2008 Purdue Research Foundation 7 7 * 8 8 * See the file "license.terms" for information on usage and … … 15 15 #include <stdlib.h> 16 16 #include <errno.h> 17 //#include <malloc.h>18 17 19 18 #ifndef _RpDICT_H … … 58 57 59 58 public: 60 61 // public data members62 63 // public member functions64 59 65 60 // retrieve the table the iterator is iterating … … 114 109 { 115 110 public: 116 117 // public member functions118 111 119 112 operator int() const; … … 133 126 void erase(); 134 127 135 // template <KeyType,ValType> friend class RpDict;136 // template <KeyType,ValType> friend class RpDictIterator;137 138 128 friend class RpDict<KeyType,ValType,_Compare>; 139 129 friend class RpDictIterator<KeyType,ValType,_Compare>; 140 141 // one-arg constructor142 // maybe get rid of this one?143 // use the clientData's default [no-arg] constructor144 /*145 RpDictEntry(KeyType newKey)146 : nextPtr (NULL),147 tablePtr (NULL),148 hash (0),149 // clientData (NULL),150 key (newKey)151 {152 }153 */154 130 155 131 // two-arg constructor … … 164 140 } 165 141 166 /*167 RpDictEntry(KeyType* newKey, ValType* newVal)168 : nextPtr (NULL),169 tablePtr (NULL),170 hash (0),171 clientData (*newVal),172 key (*newKey)173 {174 }175 176 RpDictEntry(KeyType newKey, RpDict* table)177 : nextPtr (NULL),178 tablePtr (table),179 hash (0),180 // clientData (NULL),181 key (newKey)182 {183 }184 */185 142 // copy constructor 186 143 RpDictEntry (const RpDictEntry<KeyType,ValType,_Compare>& entry) … … 203 160 private: 204 161 205 // private data members206 162 RpDictEntry<KeyType,ValType,_Compare>* 207 163 nextPtr; /* Pointer to next entry in this … … 221 177 ValType* valid; /* is this a valid object */ 222 178 223 224 // no_arg constructor225 //226 179 RpDictEntry() 227 180 : nextPtr (NULL), … … 301 254 caseInsensitive(ci) 302 255 { 303 304 256 staticBuckets[0] = staticBuckets[1] = 0; 305 257 staticBuckets[2] = staticBuckets[3] = 0; … … 309 261 310 262 assert(nullEntry != NULL); 311 312 // std::cout << "inside RpDict Constructor" << std::endl;313 314 263 } 315 264 … … 338 287 * element points to first entry in 339 288 * bucket's hash chain, or NULL. */ 340 // RpDictEntry *staticBuckets[SMALL_RP_DICT_SIZE];341 289 RpDictEntry<KeyType,ValType,_Compare> 342 290 *staticBuckets[4]; … … 382 330 /*--------------------------------------------------------------------------*/ 383 331 384 385 // public RpDict member functions386 387 388 332 /************************************************************************** 389 333 * … … 400 344 *************************************************************************/ 401 345 402 template <typename KeyType, typename ValType, class _Compare> 403 const int 346 template <typename KeyType, typename ValType, class _Compare> 347 const int 404 348 RpDict<KeyType,ValType,_Compare>::size() const 405 349 { … … 411 355 * 412 356 * RpDict::set() 413 * checks to make sure the table exists. 357 * checks to make sure the table exists. 414 358 * places a key/value pair into the hash table 415 359 * 416 360 * Results: 417 361 * Returns a reference to the RpDict object allowing the user to chain 418 * together different commands such as 362 * together different commands such as 419 363 * rpdict_obj.set(key).find(a).erase(a); 420 364 * … … 1015 959 /*************************************************************************/ 1016 960 1017 // private member functions1018 1019 961 /* 1020 962 *---------------------------------------------------------------------- … … 1046 988 RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL; 1047 989 1048 // void *key = NULL;1049 1050 990 oldSize = numBuckets; 1051 991 oldBuckets = buckets; … … 1063 1003 1064 1004 for (count = numBuckets, newChainPtr = buckets; 1065 count > 0; 1005 count > 0; 1066 1006 count--, newChainPtr++) { 1067 1007 … … 1080 1020 for (hPtr = *oldChainPtr; hPtr != NULL; hPtr = *oldChainPtr) { 1081 1021 *oldChainPtr = hPtr->nextPtr; 1082 1083 // key = (void *) hPtr->getKey();1084 1022 1085 1023 index = randomIndex(hPtr->hash);
Note: See TracChangeset
for help on using the changeset viewer.