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

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

Issue 2747213002: Migrate WTF::Deque::last() to ::back() (Closed)
Patch Set: rebase 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 T& front() { 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& front() 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& back() {
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& back() const {
107 DCHECK_NE(m_start, m_end); 107 DCHECK_NE(m_start, m_end);
108 return *(--end()); 108 return *(--end());
109 } 109 }
110 T takeLast(); 110 T takeLast();
111 111
112 T& at(size_t i) { 112 T& at(size_t i) {
113 RELEASE_ASSERT(i < size()); 113 RELEASE_ASSERT(i < size());
114 size_t right = m_buffer.capacity() - m_start; 114 size_t right = m_buffer.capacity() - m_start;
115 return i < right ? m_buffer.buffer()[m_start + i] 115 return i < right ? m_buffer.buffer()[m_start + i]
116 : m_buffer.buffer()[i - right]; 116 : m_buffer.buffer()[i - right];
(...skipping 16 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& back() { return last(); }
144 const T& back() const { return last(); }
145 template <typename... Args> 143 template <typename... Args>
146 void emplace_back(Args&&...); 144 void emplace_back(Args&&...);
147 template <typename... Args> 145 template <typename... Args>
148 void emplace_front(Args&&...); 146 void emplace_front(Args&&...);
149 147
150 void clear(); 148 void clear();
151 149
152 template <typename VisitorDispatcher> 150 template <typename VisitorDispatcher>
153 void trace(VisitorDispatcher); 151 void trace(VisitorDispatcher);
154 152
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 480
483 template <typename T, size_t inlineCapacity, typename Allocator> 481 template <typename T, size_t inlineCapacity, typename Allocator>
484 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() { 482 inline T Deque<T, inlineCapacity, Allocator>::takeFirst() {
485 T oldFirst = std::move(front()); 483 T oldFirst = std::move(front());
486 pop_front(); 484 pop_front();
487 return oldFirst; 485 return oldFirst;
488 } 486 }
489 487
490 template <typename T, size_t inlineCapacity, typename Allocator> 488 template <typename T, size_t inlineCapacity, typename Allocator>
491 inline T Deque<T, inlineCapacity, Allocator>::takeLast() { 489 inline T Deque<T, inlineCapacity, Allocator>::takeLast() {
492 T oldLast = std::move(last()); 490 T oldLast = std::move(back());
493 pop_back(); 491 pop_back();
494 return oldLast; 492 return oldLast;
495 } 493 }
496 494
497 template <typename T, size_t inlineCapacity, typename Allocator> 495 template <typename T, size_t inlineCapacity, typename Allocator>
498 template <typename U> 496 template <typename U>
499 inline void Deque<T, inlineCapacity, Allocator>::push_back(U&& value) { 497 inline void Deque<T, inlineCapacity, Allocator>::push_back(U&& value) {
500 expandCapacityIfNeeded(); 498 expandCapacityIfNeeded();
501 T* newElement = &m_buffer.buffer()[m_end]; 499 T* newElement = &m_buffer.buffer()[m_end];
502 if (m_end == m_buffer.capacity() - 1) 500 if (m_end == m_buffer.capacity() - 1)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 inline void swap(Deque<T, inlineCapacity, Allocator>& a, 701 inline void swap(Deque<T, inlineCapacity, Allocator>& a,
704 Deque<T, inlineCapacity, Allocator>& b) { 702 Deque<T, inlineCapacity, Allocator>& b) {
705 a.swap(b); 703 a.swap(b);
706 } 704 }
707 705
708 } // namespace WTF 706 } // namespace WTF
709 707
710 using WTF::Deque; 708 using WTF::Deque;
711 709
712 #endif // WTF_Deque_h 710 #endif // WTF_Deque_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698