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

Unified Diff: third_party/WebKit/Source/wtf/NonCopyingSort.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/MathExtrasTest.cpp ('k') | third_party/WebKit/Source/wtf/Noncopyable.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/NonCopyingSort.h
diff --git a/third_party/WebKit/Source/wtf/NonCopyingSort.h b/third_party/WebKit/Source/wtf/NonCopyingSort.h
index 4315429e734cac1dceb94f6bbbd03656baec50ef..d913b5b6144077e46576840374b95e005f3e4113 100644
--- a/third_party/WebKit/Source/wtf/NonCopyingSort.h
+++ b/third_party/WebKit/Source/wtf/NonCopyingSort.h
@@ -32,60 +32,65 @@ namespace WTF {
using std::swap;
template <typename RandomAccessIterator, typename Predicate>
-inline void siftDown(RandomAccessIterator array, ptrdiff_t start, ptrdiff_t end, Predicate compareLess)
-{
- ptrdiff_t root = start;
+inline void siftDown(RandomAccessIterator array,
+ ptrdiff_t start,
+ ptrdiff_t end,
+ Predicate compareLess) {
+ ptrdiff_t root = start;
- while (root * 2 + 1 <= end) {
- ptrdiff_t child = root * 2 + 1;
- if (child < end && compareLess(array[child], array[child + 1]))
- child++;
+ while (root * 2 + 1 <= end) {
+ ptrdiff_t child = root * 2 + 1;
+ if (child < end && compareLess(array[child], array[child + 1]))
+ child++;
- if (compareLess(array[root], array[child])) {
- swap(array[root], array[child]);
- root = child;
- } else {
- return;
- }
+ if (compareLess(array[root], array[child])) {
+ swap(array[root], array[child]);
+ root = child;
+ } else {
+ return;
}
+ }
}
template <typename RandomAccessIterator, typename Predicate>
-inline void heapify(RandomAccessIterator array, ptrdiff_t count, Predicate compareLess)
-{
- ptrdiff_t start = (count - 2) / 2;
+inline void heapify(RandomAccessIterator array,
+ ptrdiff_t count,
+ Predicate compareLess) {
+ ptrdiff_t start = (count - 2) / 2;
- while (start >= 0) {
- siftDown(array, start, count - 1, compareLess);
- start--;
- }
+ while (start >= 0) {
+ siftDown(array, start, count - 1, compareLess);
+ start--;
+ }
}
template <typename RandomAccessIterator, typename Predicate>
-void heapSort(RandomAccessIterator start, RandomAccessIterator end, Predicate compareLess)
-{
- ptrdiff_t count = end - start;
- heapify(start, count, compareLess);
+void heapSort(RandomAccessIterator start,
+ RandomAccessIterator end,
+ Predicate compareLess) {
+ ptrdiff_t count = end - start;
+ heapify(start, count, compareLess);
- ptrdiff_t endIndex = count - 1;
- while (endIndex > 0) {
- swap(start[endIndex], start[0]);
- siftDown(start, 0, endIndex - 1, compareLess);
- endIndex--;
- }
+ ptrdiff_t endIndex = count - 1;
+ while (endIndex > 0) {
+ swap(start[endIndex], start[0]);
+ siftDown(start, 0, endIndex - 1, compareLess);
+ endIndex--;
+ }
}
template <typename RandomAccessIterator, typename Predicate>
-inline void nonCopyingSort(RandomAccessIterator start, RandomAccessIterator end, Predicate compareLess)
-{
- // heapsort happens to use only swaps, not copies, but the essential thing
- // about this function is the fact that it does not copy, not the specific
- // algorithm
- heapSort(start, end, compareLess);
+inline void nonCopyingSort(RandomAccessIterator start,
+ RandomAccessIterator end,
+ Predicate compareLess) {
+ // heapsort happens to use only swaps, not copies, but the essential thing
+ // about this function is the fact that it does not copy, not the specific
+ // algorithm
+ heapSort(start, end, compareLess);
}
-} // namespace WTF
+} // namespace WTF
using WTF::nonCopyingSort;
-#endif // WTF_NonCopyingSort_h
+#endif // WTF_NonCopyingSort_h
« no previous file with comments | « third_party/WebKit/Source/wtf/MathExtrasTest.cpp ('k') | third_party/WebKit/Source/wtf/Noncopyable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698