src/share/vm/libadt/dict.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Cdiff src/share/vm/libadt/dict.hpp

src/share/vm/libadt/dict.hpp

Print this page

        

*** 23,55 **** */ #ifndef SHARE_VM_LIBADT_DICT_HPP #define SHARE_VM_LIBADT_DICT_HPP - #include "libadt/port.hpp" - // Dictionaries - An Abstract Data Type ! //INTERFACE ! class ostream; class Dict; // These dictionaries define a key-value mapping. They can be inserted to, // searched or deleted from. They grow and shrink as needed. The key is a // pointer to something (or anything which can be stored in a pointer). A // key comparison routine determines if two keys are equal or not. A hash // function can be provided; if it's not provided the key itself is used // instead. A nice string hash function is included. ! typedef int32 (*CmpKey)(const void *key1, const void *key2); typedef int (*Hash)(const void *key); typedef void (*FuncDict)(const void *key, const void *val, Dict *d); class Dict : public ResourceObj { // Dictionary structure private: class Arena *_arena; // Where to draw storage from class bucket *_bin; // Hash table is array of buckets uint _size; // Size (# of slots) in hash table ! uint32 _cnt; // Number of key-value pairs in hash table const Hash _hash; // Hashing function const CmpKey _cmp; // Key comparison function void doubhash( void ); // Double hash table size public: --- 23,56 ---- */ #ifndef SHARE_VM_LIBADT_DICT_HPP #define SHARE_VM_LIBADT_DICT_HPP // Dictionaries - An Abstract Data Type ! ! #include "memory/allocation.inline.hpp" ! #include "memory/resourceArea.hpp" ! #include "runtime/thread.hpp" ! class Dict; // These dictionaries define a key-value mapping. They can be inserted to, // searched or deleted from. They grow and shrink as needed. The key is a // pointer to something (or anything which can be stored in a pointer). A // key comparison routine determines if two keys are equal or not. A hash // function can be provided; if it's not provided the key itself is used // instead. A nice string hash function is included. ! typedef int32_t (*CmpKey)(const void *key1, const void *key2); typedef int (*Hash)(const void *key); typedef void (*FuncDict)(const void *key, const void *val, Dict *d); class Dict : public ResourceObj { // Dictionary structure private: class Arena *_arena; // Where to draw storage from class bucket *_bin; // Hash table is array of buckets uint _size; // Size (# of slots) in hash table ! uint32_t _cnt; // Number of key-value pairs in hash table const Hash _hash; // Hashing function const CmpKey _cmp; // Key comparison function void doubhash( void ); // Double hash table size public:
*** 65,75 **** // Zap to empty; ready for re-use void Clear(); // Return # of key-value pairs in dict ! uint32 Size(void) const { return _cnt; } // Insert inserts the given key-value pair into the dictionary. The prior // value of the key is returned; NULL if the key was not previously defined. void *Insert(void *key, void *val, bool replace = true); // A new key-value void *Delete(void *key); // Delete & return old --- 66,76 ---- // Zap to empty; ready for re-use void Clear(); // Return # of key-value pairs in dict ! uint32_t Size(void) const { return _cnt; } // Insert inserts the given key-value pair into the dictionary. The prior // value of the key is returned; NULL if the key was not previously defined. void *Insert(void *key, void *val, bool replace = true); // A new key-value void *Delete(void *key); // Delete & return old
*** 79,89 **** void *operator [](const void *key) const; // Do a lookup // == compares two dictionaries; they must have the same keys (their keys // must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. ! int32 operator ==(const Dict &d) const; // Compare dictionaries for equal // Print out the dictionary contents as key-value pairs void print(); }; --- 80,90 ---- void *operator [](const void *key) const; // Do a lookup // == compares two dictionaries; they must have the same keys (their keys // must match using CmpKey) and they must have the same values (pointer // comparison). If so 1 is returned, if not 0 is returned. ! int32_t operator ==(const Dict &d) const; // Compare dictionaries for equal // Print out the dictionary contents as key-value pairs void print(); };
*** 94,106 **** int hashptr(const void *key); // Slimey cheap hash function; no guaranteed performance. int hashkey(const void *key); // Key comparators ! int32 cmpstr(const void *k1, const void *k2); // Slimey cheap key comparator. ! int32 cmpkey(const void *key1, const void *key2); //------------------------------Iteration-------------------------------------- // The class of dictionary iterators. Fails in the presences of modifications // to the dictionary during iteration (including searches). // Usage: for( DictI i(dict); i.test(); ++i ) { body = i.key; body = i.value;} --- 95,107 ---- int hashptr(const void *key); // Slimey cheap hash function; no guaranteed performance. int hashkey(const void *key); // Key comparators ! int32_t cmpstr(const void *k1, const void *k2); // Slimey cheap key comparator. ! int32_t cmpkey(const void *key1, const void *key2); //------------------------------Iteration-------------------------------------- // The class of dictionary iterators. Fails in the presences of modifications // to the dictionary during iteration (including searches). // Usage: for( DictI i(dict); i.test(); ++i ) { body = i.key; body = i.value;}
src/share/vm/libadt/dict.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File