| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 39 class Allocator BASE_EMBEDDED { | 39 class Allocator BASE_EMBEDDED { | 
| 40  public: | 40  public: | 
| 41   virtual ~Allocator()  {} | 41   virtual ~Allocator()  {} | 
| 42   virtual void* New(size_t size)  { return Malloced::New(size); } | 42   virtual void* New(size_t size)  { return Malloced::New(size); } | 
| 43   virtual void Delete(void* p)  { Malloced::Delete(p); } | 43   virtual void Delete(void* p)  { Malloced::Delete(p); } | 
| 44 }; | 44 }; | 
| 45 | 45 | 
| 46 | 46 | 
| 47 class HashMap { | 47 class HashMap { | 
| 48  public: | 48  public: | 
| 49   static Allocator DefaultAllocator; | 49   static Allocator* DefaultAllocator; | 
| 50 | 50 | 
| 51   typedef bool (*MatchFun) (void* key1, void* key2); | 51   typedef bool (*MatchFun) (void* key1, void* key2); | 
| 52 | 52 | 
| 53   // initial_capacity is the size of the initial hash map; | 53   // initial_capacity is the size of the initial hash map; | 
| 54   // it must be a power of 2 (and thus must not be 0). | 54   // it must be a power of 2 (and thus must not be 0). | 
| 55   explicit HashMap(MatchFun match, | 55   explicit HashMap(MatchFun match, | 
| 56                    Allocator* allocator = &DefaultAllocator, | 56                    Allocator* allocator = DefaultAllocator, | 
| 57                    uint32_t initial_capacity = 8); | 57                    uint32_t initial_capacity = 8); | 
| 58 | 58 | 
| 59   ~HashMap(); | 59   ~HashMap(); | 
| 60 | 60 | 
| 61   // HashMap entries are (key, value, hash) triplets. | 61   // HashMap entries are (key, value, hash) triplets. | 
| 62   // Some clients may not need to use the value slot | 62   // Some clients may not need to use the value slot | 
| 63   // (e.g. implementers of sets, where the key is the value). | 63   // (e.g. implementers of sets, where the key is the value). | 
| 64   struct Entry { | 64   struct Entry { | 
| 65     void* key; | 65     void* key; | 
| 66     void* value; | 66     void* value; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109   Entry* map_end() const { return map_ + capacity_; } | 109   Entry* map_end() const { return map_ + capacity_; } | 
| 110   Entry* Probe(void* key, uint32_t hash); | 110   Entry* Probe(void* key, uint32_t hash); | 
| 111   void Initialize(uint32_t capacity); | 111   void Initialize(uint32_t capacity); | 
| 112   void Resize(); | 112   void Resize(); | 
| 113 }; | 113 }; | 
| 114 | 114 | 
| 115 | 115 | 
| 116 } }  // namespace v8::internal | 116 } }  // namespace v8::internal | 
| 117 | 117 | 
| 118 #endif  // V8_HASHMAP_H_ | 118 #endif  // V8_HASHMAP_H_ | 
| OLD | NEW | 
|---|