| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #ifndef SRC_VM_HASH_MAP_H_ | 5 #ifndef SRC_VM_HASH_MAP_H_ |
| 6 #define SRC_VM_HASH_MAP_H_ | 6 #define SRC_VM_HASH_MAP_H_ |
| 7 | 7 |
| 8 #include "src/vm/hash_table.h" | 8 #include "src/vm/hash_table.h" |
| 9 | 9 |
| 10 namespace fletch { | 10 namespace dartino { |
| 11 | 11 |
| 12 template <typename Key, typename Mapped> | 12 template <typename Key, typename Mapped> |
| 13 struct MapKeyExtractor { | 13 struct MapKeyExtractor { |
| 14 static Key& GetKey(Pair<Key, Mapped>& pair) { // NOLINT | 14 static Key& GetKey(Pair<Key, Mapped>& pair) { // NOLINT |
| 15 return pair.first; | 15 return pair.first; |
| 16 } | 16 } |
| 17 | 17 |
| 18 static const Key& GetKey(const Pair<Key, Mapped>& pair) { return pair.first; } | 18 static const Key& GetKey(const Pair<Key, Mapped>& pair) { return pair.first; } |
| 19 }; | 19 }; |
| 20 | 20 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 MappedType& At(const Key& key) { | 44 MappedType& At(const Key& key) { |
| 45 char* mapped = this->map_.At(reinterpret_cast<const void*>(key)); | 45 char* mapped = this->map_.At(reinterpret_cast<const void*>(key)); |
| 46 // The original API throws an exception, but we don't use exceptions. | 46 // The original API throws an exception, but we don't use exceptions. |
| 47 ASSERT(mapped != NULL); | 47 ASSERT(mapped != NULL); |
| 48 return *reinterpret_cast<MappedType*>(mapped); | 48 return *reinterpret_cast<MappedType*>(mapped); |
| 49 } | 49 } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace fletch | 52 } // namespace dartino |
| 53 | 53 |
| 54 #endif // SRC_VM_HASH_MAP_H_ | 54 #endif // SRC_VM_HASH_MAP_H_ |
| OLD | NEW |