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

Side by Side Diff: src/core/SkSinglyLinkedList.h

Issue 1953153004: SkAdvancedTypefaceMetrics: abstract out linked list (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-05-06 (Friday) 17:00:24 EDT Created 4 years, 7 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/core/SkAdvancedTypefaceMetrics.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #ifndef SkSinglyLinkedList_DEFINED 7 #ifndef SkSinglyLinkedList_DEFINED
8 #define SkSinglyLinkedList_DEFINED 8 #define SkSinglyLinkedList_DEFINED
9 9
10 #include <utility> 10 #include <utility>
(...skipping 13 matching lines...) Expand all
24 Node* next = node->fNext; 24 Node* next = node->fNext;
25 SkASSERT(next != nullptr || node == fTail); 25 SkASSERT(next != nullptr || node == fTail);
26 delete node; 26 delete node;
27 node = next; 27 node = next;
28 } 28 }
29 fHead = nullptr; 29 fHead = nullptr;
30 fTail = nullptr; 30 fTail = nullptr;
31 } 31 }
32 T* back() { return fTail ? &fTail->fData : nullptr; } 32 T* back() { return fTail ? &fTail->fData : nullptr; }
33 T* front() { return fHead ? &fHead->fData : nullptr; } 33 T* front() { return fHead ? &fHead->fData : nullptr; }
34 bool empty() const { return fHead == nullptr; }
34 #ifdef SK_DEBUG 35 #ifdef SK_DEBUG
35 int count() { // O(n), debug only. 36 int count() { // O(n), debug only.
36 int count = 0; 37 int count = 0;
37 for (Node* node = fHead; node; node = node->fNext) { 38 for (Node* node = fHead; node; node = node->fNext) {
38 ++count; 39 ++count;
39 } 40 }
40 return count; 41 return count;
41 } 42 }
42 #endif 43 #endif
43 void pop_front() { 44 void pop_front() {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 Node* fNext; 88 Node* fNext;
88 template <class... Args> 89 template <class... Args>
89 Node(Args&&... args) : fData(std::forward<Args>(args)...), fNext(nullptr ) {} 90 Node(Args&&... args) : fData(std::forward<Args>(args)...), fNext(nullptr ) {}
90 }; 91 };
91 Node* fHead; 92 Node* fHead;
92 Node* fTail; 93 Node* fTail;
93 SkSinglyLinkedList(const SkSinglyLinkedList<T>&) = delete; 94 SkSinglyLinkedList(const SkSinglyLinkedList<T>&) = delete;
94 SkSinglyLinkedList& operator=(const SkSinglyLinkedList<T>&) = delete; 95 SkSinglyLinkedList& operator=(const SkSinglyLinkedList<T>&) = delete;
95 }; 96 };
96 #endif // SkSinglyLinkedList_DEFINED 97 #endif // SkSinglyLinkedList_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698