Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/Deque.h |
| diff --git a/third_party/WebKit/Source/wtf/Deque.h b/third_party/WebKit/Source/wtf/Deque.h |
| index f244bb52846c86533603a7947db9d2ac2b2e15b3..7937801026b1073a016ce3a60fa20a88fe1a7351 100644 |
| --- a/third_party/WebKit/Source/wtf/Deque.h |
| +++ b/third_party/WebKit/Source/wtf/Deque.h |
| @@ -134,6 +134,27 @@ class Deque : public ConditionalDestructor<Deque<T, INLINE_CAPACITY, Allocator>, |
| void remove(iterator&); |
| void remove(const_iterator&); |
| + // STL compatibility. |
| + template <typename U> |
| + void push_back(U&& u) { |
| + append(std::forward<U>(u)); |
| + } |
| + template <typename U> |
| + void push_front(U&& u) { |
| + prepend(std::forward<U>(u)); |
| + } |
| + void pop_back() { removeLast(); } |
| + void pop_front() { removeFirst(); } |
| + bool empty() const { return isEmpty(); } |
| + T& front() { return first(); } |
| + const T& front() const { return first(); } |
| + T& back() { return last(); } |
| + const T& back() const { return last(); } |
| + template <typename... Args> |
| + void emplace_back(Args&&...); |
| + template <typename... Args> |
| + void emplace_front(Args&&...); |
| + |
| void clear(); |
| template <typename VisitorDispatcher> |
| @@ -504,6 +525,28 @@ inline void Deque<T, inlineCapacity, Allocator>::prepend(U&& value) { |
| } |
| template <typename T, size_t inlineCapacity, typename Allocator> |
| +template <typename... Args> |
| +inline void Deque<T, inlineCapacity, Allocator>::emplace_back(Args&&... args) { |
| + expandCapacityIfNeeded(); |
| + new (NotNull, &m_buffer.buffer()[m_end]) T(std::forward<Args>(args)...); |
| + if (m_end == m_buffer.capacity() - 1) |
|
Sami
2017/01/11 13:49:11
Looks like this already exists with the current co
alex clarke (OOO till 29th)
2017/01/11 14:04:26
Done.
|
| + m_end = 0; |
| + else |
| + ++m_end; |
| +} |
| + |
| +template <typename T, size_t inlineCapacity, typename Allocator> |
| +template <typename... Args> |
| +inline void Deque<T, inlineCapacity, Allocator>::emplace_front(Args&&... args) { |
| + expandCapacityIfNeeded(); |
| + if (!m_start) |
| + m_start = m_buffer.capacity() - 1; |
| + else |
| + --m_start; |
| + new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<Args>(args)...); |
| +} |
| + |
| +template <typename T, size_t inlineCapacity, typename Allocator> |
| inline void Deque<T, inlineCapacity, Allocator>::removeFirst() { |
| DCHECK(!isEmpty()); |
| TypeOperations::destruct(&m_buffer.buffer()[m_start], |