| OLD | NEW |
| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 RELEASE_ASSERT(i < size()); | 119 RELEASE_ASSERT(i < size()); |
| 120 size_t right = m_buffer.capacity() - m_start; | 120 size_t right = m_buffer.capacity() - m_start; |
| 121 return i < right ? m_buffer.buffer()[m_start + i] | 121 return i < right ? m_buffer.buffer()[m_start + i] |
| 122 : m_buffer.buffer()[i - right]; | 122 : m_buffer.buffer()[i - right]; |
| 123 } | 123 } |
| 124 | 124 |
| 125 T& operator[](size_t i) { return at(i); } | 125 T& operator[](size_t i) { return at(i); } |
| 126 const T& operator[](size_t i) const { return at(i); } | 126 const T& operator[](size_t i) const { return at(i); } |
| 127 | 127 |
| 128 template <typename U> | 128 template <typename U> |
| 129 void append(U&&); | |
| 130 template <typename U> | |
| 131 void prepend(U&&); | 129 void prepend(U&&); |
| 132 void removeFirst(); | 130 void removeFirst(); |
| 133 void remove(iterator&); | 131 void remove(iterator&); |
| 134 void remove(const_iterator&); | 132 void remove(const_iterator&); |
| 135 | 133 |
| 136 // STL compatibility. | 134 // STL compatibility. |
| 137 template <typename U> | 135 template <typename U> |
| 138 void push_back(U&& u) { | 136 void push_back(U&&); |
| 139 append(std::forward<U>(u)); | |
| 140 } | |
| 141 template <typename U> | 137 template <typename U> |
| 142 void push_front(U&& u) { | 138 void push_front(U&& u) { |
| 143 prepend(std::forward<U>(u)); | 139 prepend(std::forward<U>(u)); |
| 144 } | 140 } |
| 145 void pop_back(); | 141 void pop_back(); |
| 146 void pop_front() { removeFirst(); } | 142 void pop_front() { removeFirst(); } |
| 147 bool empty() const { return isEmpty(); } | 143 bool empty() const { return isEmpty(); } |
| 148 T& front() { return first(); } | 144 T& front() { return first(); } |
| 149 const T& front() const { return first(); } | 145 const T& front() const { return first(); } |
| 150 T& back() { return last(); } | 146 T& back() { return last(); } |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 492 |
| 497 template <typename T, size_t inlineCapacity, typename Allocator> | 493 template <typename T, size_t inlineCapacity, typename Allocator> |
| 498 inline T Deque<T, inlineCapacity, Allocator>::takeLast() { | 494 inline T Deque<T, inlineCapacity, Allocator>::takeLast() { |
| 499 T oldLast = std::move(last()); | 495 T oldLast = std::move(last()); |
| 500 pop_back(); | 496 pop_back(); |
| 501 return oldLast; | 497 return oldLast; |
| 502 } | 498 } |
| 503 | 499 |
| 504 template <typename T, size_t inlineCapacity, typename Allocator> | 500 template <typename T, size_t inlineCapacity, typename Allocator> |
| 505 template <typename U> | 501 template <typename U> |
| 506 inline void Deque<T, inlineCapacity, Allocator>::append(U&& value) { | 502 inline void Deque<T, inlineCapacity, Allocator>::push_back(U&& value) { |
| 507 expandCapacityIfNeeded(); | 503 expandCapacityIfNeeded(); |
| 508 T* newElement = &m_buffer.buffer()[m_end]; | 504 T* newElement = &m_buffer.buffer()[m_end]; |
| 509 if (m_end == m_buffer.capacity() - 1) | 505 if (m_end == m_buffer.capacity() - 1) |
| 510 m_end = 0; | 506 m_end = 0; |
| 511 else | 507 else |
| 512 ++m_end; | 508 ++m_end; |
| 513 new (NotNull, newElement) T(std::forward<U>(value)); | 509 new (NotNull, newElement) T(std::forward<U>(value)); |
| 514 } | 510 } |
| 515 | 511 |
| 516 template <typename T, size_t inlineCapacity, typename Allocator> | 512 template <typename T, size_t inlineCapacity, typename Allocator> |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 inline void swap(Deque<T, inlineCapacity, Allocator>& a, | 706 inline void swap(Deque<T, inlineCapacity, Allocator>& a, |
| 711 Deque<T, inlineCapacity, Allocator>& b) { | 707 Deque<T, inlineCapacity, Allocator>& b) { |
| 712 a.swap(b); | 708 a.swap(b); |
| 713 } | 709 } |
| 714 | 710 |
| 715 } // namespace WTF | 711 } // namespace WTF |
| 716 | 712 |
| 717 using WTF::Deque; | 713 using WTF::Deque; |
| 718 | 714 |
| 719 #endif // WTF_Deque_h | 715 #endif // WTF_Deque_h |
| OLD | NEW |