hotspot/src/share/vm/libadt/dict.cpp

Print this page
rev 611 : Merge


 332 // Slimey cheap hash function; no guarenteed performance.  Better than the
 333 // default for pointers, especially on MS-DOS machines.
 334 int hashptr(const void *key) {
 335 #ifdef __TURBOC__
 336     return ((intptr_t)key >> 16);
 337 #else  // __TURBOC__
 338     return ((intptr_t)key >> 2);
 339 #endif
 340 }
 341 
 342 // Slimey cheap hash function; no guarenteed performance.
 343 int hashkey(const void *key) {
 344   return (intptr_t)key;
 345 }
 346 
 347 //------------------------------Key Comparator Functions---------------------
 348 int32 cmpstr(const void *k1, const void *k2) {
 349   return strcmp((const char *)k1,(const char *)k2);
 350 }
 351 
 352 // Slimey cheap key comparator.
 353 int32 cmpkey(const void *key1, const void *key2) {
 354   return (int32)((intptr_t)key1 - (intptr_t)key2);



 355 }
 356 
 357 //=============================================================================
 358 //------------------------------reset------------------------------------------
 359 // Create an iterator and initialize the first variables.
 360 void DictI::reset( const Dict *dict ) {
 361   _d = dict;                    // The dictionary
 362   _i = (uint)-1;                // Before the first bin
 363   _j = 0;                       // Nothing left in the current bin
 364   ++(*this);                    // Step to first real value
 365 }
 366 
 367 //------------------------------next-------------------------------------------
 368 // Find the next key-value pair in the dictionary, or return a NULL key and
 369 // value.
 370 void DictI::operator ++(void) {
 371   if( _j-- ) {                  // Still working in current bin?
 372     _key   = _d->_bin[_i]._keyvals[_j+_j];
 373     _value = _d->_bin[_i]._keyvals[_j+_j+1];
 374     return;


 332 // Slimey cheap hash function; no guarenteed performance.  Better than the
 333 // default for pointers, especially on MS-DOS machines.
 334 int hashptr(const void *key) {
 335 #ifdef __TURBOC__
 336     return ((intptr_t)key >> 16);
 337 #else  // __TURBOC__
 338     return ((intptr_t)key >> 2);
 339 #endif
 340 }
 341 
 342 // Slimey cheap hash function; no guarenteed performance.
 343 int hashkey(const void *key) {
 344   return (intptr_t)key;
 345 }
 346 
 347 //------------------------------Key Comparator Functions---------------------
 348 int32 cmpstr(const void *k1, const void *k2) {
 349   return strcmp((const char *)k1,(const char *)k2);
 350 }
 351 
 352 // Cheap key comparator.
 353 int32 cmpkey(const void *key1, const void *key2) {
 354   if (key1 == key2) return 0;
 355   intptr_t delta = (intptr_t)key1 - (intptr_t)key2;
 356   if (delta > 0) return 1;
 357   return -1;
 358 }
 359 
 360 //=============================================================================
 361 //------------------------------reset------------------------------------------
 362 // Create an iterator and initialize the first variables.
 363 void DictI::reset( const Dict *dict ) {
 364   _d = dict;                    // The dictionary
 365   _i = (uint)-1;                // Before the first bin
 366   _j = 0;                       // Nothing left in the current bin
 367   ++(*this);                    // Step to first real value
 368 }
 369 
 370 //------------------------------next-------------------------------------------
 371 // Find the next key-value pair in the dictionary, or return a NULL key and
 372 // value.
 373 void DictI::operator ++(void) {
 374   if( _j-- ) {                  // Still working in current bin?
 375     _key   = _d->_bin[_i]._keyvals[_j+_j];
 376     _value = _d->_bin[_i]._keyvals[_j+_j+1];
 377     return;