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

Side by Side Diff: third_party/WebKit/Source/wtf/Deque.h

Issue 2752593003: Migrate WTF::Deque::first() to ::front() (Closed)
Patch Set: one more platform specific reference Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const_iterator end() const { return const_iterator(this, m_end); } 82 const_iterator end() const { return const_iterator(this, m_end); }
83 reverse_iterator rbegin() { return reverse_iterator(end()); } 83 reverse_iterator rbegin() { return reverse_iterator(end()); }
84 reverse_iterator rend() { return reverse_iterator(begin()); } 84 reverse_iterator rend() { return reverse_iterator(begin()); }
85 const_reverse_iterator rbegin() const { 85 const_reverse_iterator rbegin() const {
86 return const_reverse_iterator(end()); 86 return const_reverse_iterator(end());
87 } 87 }
88 const_reverse_iterator rend() const { 88 const_reverse_iterator rend() const {
89 return const_reverse_iterator(begin()); 89 return const_reverse_iterator(begin());
90 } 90 }
91 91
92 T& first() { 92 T& front() {
93 DCHECK_NE(m_start, m_end); 93 DCHECK_NE(m_start, m_end);
94 return m_buffer.buffer()[m_start]; 94 return m_buffer.buffer()[m_start];
95 } 95 }
96 const T& first() const { 96 const T& front() const {
97 DCHECK_NE(m_start, m_end); 97 DCHECK_NE(m_start, m_end);
98 return m_buffer.buffer()[m_start]; 98 return m_buffer.buffer()[m_start];
99 } 99 }
100 T takeFirst(); 100 T takeFirst();
101 101
102 T& last() { 102 T& last() {
103 DCHECK_NE(m_start, m_end); 103 DCHECK_NE(m_start, m_end);
104 return *(--end()); 104 return *(--end());
105 } 105 }
106 const T& last() const { 106 const T& last() const {
(...skipping 26 matching lines...) Expand all
133 // STL compatibility. 133 // STL compatibility.
134 template <typename U> 134 template <typename U>
135 void push_back(U&&); 135 void push_back(U&&);
136 template <typename U> 136 template <typename U>
137 void push_front(U&& u) { 137 void push_front(U&& u) {
138 prepend(std::forward<U>(u)); 138 prepend(std::forward<U>(u));
139 } 139 }
140 void pop_back(); 140 void pop_back();
141 void pop_front(); 141 void pop_front();
142 bool empty() const { return isEmpty(); } 142 bool empty() const { return isEmpty(); }
143 T& front() { return first(); }
144 const T& front() const { return first(); }
145 T& back() { return last(); } 143 T& back() { return last(); }
146 const T& back() const { return last(); } 144 const T& back() const { return last(); }
147 template <typename... Args> 145 template <typename... Args>
148 void emplace_back(Args&&...); 146 void emplace_back(Args&&...);
149 template <typename... Args> 147 template <typename... Args>
150 void emplace_front(Args&&...); 148 void emplace_front(Args&&...);
151 149
152 void clear(); 150 void clear();
153 151
154 template <typename VisitorDispatcher> 152 template <typename VisitorDispatcher>
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity, 475 TypeOperations::move(oldBuffer + m_start, oldBuffer + oldCapacity,
478 m_buffer.buffer() + newStart); 476 m_buffer.buffer() + newStart);
479 m_buffer.clearUnusedSlots(oldBuffer + m_start, oldBuffer + oldCapacity); 477 m_buffer.clearUnusedSlots(oldBuffer + m_start, oldBuffer + oldCapacity);
480 m_start = newStart; 478 m_start = newStart;
481 } 479 }
482 m_buffer.deallocateBuffer(oldBuffer); 480 m_buffer.deallocateBuffer(oldBuffer);
483 } 481 }
484 482
485 template <typename T, size_t inlineCapacity, typename Allocator> 483 template <typename T, size_t inlineCapacity, typename Allocator>
486 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() { 484 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() {
487 T oldFirst = std::move(first()); 485 T oldFirst = std::move(front());
488 pop_front(); 486 pop_front();
489 return oldFirst; 487 return oldFirst;
490 } 488 }
491 489
492 template <typename T, size_t inlineCapacity, typename Allocator> 490 template <typename T, size_t inlineCapacity, typename Allocator>
493 inline T Deque<T, inlineCapacity, Allocator>::takeLast() { 491 inline T Deque<T, inlineCapacity, Allocator>::takeLast() {
494 T oldLast = std::move(last()); 492 T oldLast = std::move(last());
495 pop_back(); 493 pop_back();
496 return oldLast; 494 return oldLast;
497 } 495 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 703 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
706 Deque<T, inlineCapacity, Allocator>& b) { 704 Deque<T, inlineCapacity, Allocator>& b) {
707 a.swap(b); 705 a.swap(b);
708 } 706 }
709 707
710 } // namespace WTF 708 } // namespace WTF
711 709
712 using WTF::Deque; 710 using WTF::Deque;
713 711
714 #endif // WTF_Deque_h 712 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/wtf/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698