Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: src/vm/sort.h

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/vm/snapshot.cc ('k') | src/vm/sort.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SORT_H_ 5 #ifndef SRC_VM_SORT_H_
6 #define SRC_VM_SORT_H_ 6 #define SRC_VM_SORT_H_
7 7
8 #include "src/shared/assert.h" 8 #include "src/shared/assert.h"
9 9
10 namespace fletch { 10 namespace dartino {
11 11
12 typedef bool (*VoidCompare)(uint8* a, uint8* b); 12 typedef bool (*VoidCompare)(uint8* a, uint8* b);
13 13
14 void VoidSort(uint8* buffer, size_t elements, size_t element_size, 14 void VoidSort(uint8* buffer, size_t elements, size_t element_size,
15 VoidCompare compare); 15 VoidCompare compare);
16 16
17 template <typename T> 17 template <typename T>
18 struct SortType { 18 struct SortType {
19 typedef bool (*Compare)(const T& a, const T& b); 19 typedef bool (*Compare)(const T& a, const T& b);
20 typedef bool (*PointerCompare)(const T* a, const T* b); 20 typedef bool (*PointerCompare)(const T* a, const T* b);
21 }; 21 };
22 22
23 template <typename T> 23 template <typename T>
24 void Sort(T* from, size_t elements, typename SortType<T>::Compare compare) { 24 void Sort(T* from, size_t elements, typename SortType<T>::Compare compare) {
25 VoidSort(reinterpret_cast<uint8*>(from), elements, sizeof(T), 25 VoidSort(reinterpret_cast<uint8*>(from), elements, sizeof(T),
26 reinterpret_cast<VoidCompare>(compare)); 26 reinterpret_cast<VoidCompare>(compare));
27 } 27 }
28 28
29 template <typename T> 29 template <typename T>
30 void Sort(T* from, size_t elements, 30 void Sort(T* from, size_t elements,
31 typename SortType<T>::PointerCompare compare) { 31 typename SortType<T>::PointerCompare compare) {
32 VoidSort(reinterpret_cast<uint8*>(from), elements, sizeof(T), 32 VoidSort(reinterpret_cast<uint8*>(from), elements, sizeof(T),
33 reinterpret_cast<VoidCompare>(compare)); 33 reinterpret_cast<VoidCompare>(compare));
34 } 34 }
35 35
36 } // namespace fletch 36 } // namespace dartino
37 37
38 #endif // SRC_VM_SORT_H_ 38 #endif // SRC_VM_SORT_H_
OLDNEW
« no previous file with comments | « src/vm/snapshot.cc ('k') | src/vm/sort.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698