| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_HASH_TABLE_H_ | 5 #ifndef VM_HASH_TABLE_H_ |
| 6 #define VM_HASH_TABLE_H_ | 6 #define VM_HASH_TABLE_H_ |
| 7 | 7 |
| 8 // Temporarily used when sorting the indices in EnumIndexHashTable. | 8 // Temporarily used when sorting the indices in EnumIndexHashTable. |
| 9 // TODO(koda): Remove these dependencies before using in production. | 9 // TODO(koda): Remove these dependencies before using in production. |
| 10 #include <map> | 10 #include <map> |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // Allocates and initializes a table. | 428 // Allocates and initializes a table. |
| 429 template<typename Table> | 429 template<typename Table> |
| 430 static RawArray* New(intptr_t initial_capacity, | 430 static RawArray* New(intptr_t initial_capacity, |
| 431 Heap::Space space = Heap::kNew) { | 431 Heap::Space space = Heap::kNew) { |
| 432 Table table(Array::New( | 432 Table table(Array::New( |
| 433 Table::ArrayLengthForNumOccupied(initial_capacity), space)); | 433 Table::ArrayLengthForNumOccupied(initial_capacity), space)); |
| 434 table.Initialize(); | 434 table.Initialize(); |
| 435 return table.Release().raw(); | 435 return table.Release().raw(); |
| 436 } | 436 } |
| 437 | 437 |
| 438 template<typename Table> |
| 439 static RawArray* New(const Array& array) { |
| 440 Table table(array.raw()); |
| 441 table.Initialize(); |
| 442 return table.Release().raw(); |
| 443 } |
| 444 |
| 438 // Clears 'to' and inserts all elements from 'from', in iteration order. | 445 // Clears 'to' and inserts all elements from 'from', in iteration order. |
| 439 // The tables must have the same user payload size. | 446 // The tables must have the same user payload size. |
| 440 template<typename From, typename To> | 447 template<typename From, typename To> |
| 441 static void Copy(const From& from, const To& to) { | 448 static void Copy(const From& from, const To& to) { |
| 442 COMPILE_ASSERT(From::kPayloadSize == To::kPayloadSize); | 449 COMPILE_ASSERT(From::kPayloadSize == To::kPayloadSize); |
| 443 to.Initialize(); | 450 to.Initialize(); |
| 444 ASSERT(from.NumOccupied() < to.NumEntries()); | 451 ASSERT(from.NumOccupied() < to.NumEntries()); |
| 445 typename From::Iterator it(&from); | 452 typename From::Iterator it(&from); |
| 446 Object& obj = Object::Handle(); | 453 Object& obj = Object::Handle(); |
| 447 while (it.MoveNext()) { | 454 while (it.MoveNext()) { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 class EnumIndexHashSet : public HashSet<EnumIndexHashTable<KeyTraits, 0> > { | 698 class EnumIndexHashSet : public HashSet<EnumIndexHashTable<KeyTraits, 0> > { |
| 692 public: | 699 public: |
| 693 typedef HashSet<EnumIndexHashTable<KeyTraits, 0> > BaseSet; | 700 typedef HashSet<EnumIndexHashTable<KeyTraits, 0> > BaseSet; |
| 694 explicit EnumIndexHashSet(RawArray* data) : BaseSet(data) {} | 701 explicit EnumIndexHashSet(RawArray* data) : BaseSet(data) {} |
| 695 EnumIndexHashSet(Zone* zone, RawArray* data) : BaseSet(zone, data) {} | 702 EnumIndexHashSet(Zone* zone, RawArray* data) : BaseSet(zone, data) {} |
| 696 }; | 703 }; |
| 697 | 704 |
| 698 } // namespace dart | 705 } // namespace dart |
| 699 | 706 |
| 700 #endif // VM_HASH_TABLE_H_ | 707 #endif // VM_HASH_TABLE_H_ |
| OLD | NEW |