OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 void push_front(U&&); | 1162 void push_front(U&&); |
1163 template <typename U> | 1163 template <typename U> |
1164 void push_front(const U*, size_t); | 1164 void push_front(const U*, size_t); |
1165 template <typename U, size_t otherCapacity, typename OtherAllocator> | 1165 template <typename U, size_t otherCapacity, typename OtherAllocator> |
1166 void prependVector(const Vector<U, otherCapacity, OtherAllocator>&); | 1166 void prependVector(const Vector<U, otherCapacity, OtherAllocator>&); |
1167 | 1167 |
1168 // Remove an element or elements at the specified position. These functions | 1168 // Remove an element or elements at the specified position. These functions |
1169 // take O(size())-time. All of the elements after the removed ones will be | 1169 // take O(size())-time. All of the elements after the removed ones will be |
1170 // moved to the new locations. All the iterators pointing to any element | 1170 // moved to the new locations. All the iterators pointing to any element |
1171 // after |position| will be invalidated. | 1171 // after |position| will be invalidated. |
1172 void remove(size_t position); | 1172 void erase(size_t position); |
1173 void remove(size_t position, size_t length); | 1173 void erase(size_t position, size_t length); |
1174 | 1174 |
1175 // Remove the last element. Unlike remove(), (1) this function is fast, and | 1175 // Remove the last element. Unlike remove(), (1) this function is fast, and |
1176 // (2) only iterators pointing to the last element will be invalidated. Other | 1176 // (2) only iterators pointing to the last element will be invalidated. Other |
1177 // references will remain valid. | 1177 // references will remain valid. |
1178 void pop_back() { | 1178 void pop_back() { |
1179 DCHECK(!isEmpty()); | 1179 DCHECK(!isEmpty()); |
1180 shrink(size() - 1); | 1180 shrink(size() - 1); |
1181 } | 1181 } |
1182 | 1182 |
1183 // Filling the vector with the same value. If the vector has shrinked or | 1183 // Filling the vector with the same value. If the vector has shrinked or |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 } | 1807 } |
1808 | 1808 |
1809 template <typename T, size_t inlineCapacity, typename Allocator> | 1809 template <typename T, size_t inlineCapacity, typename Allocator> |
1810 template <typename U, size_t otherCapacity, typename OtherAllocator> | 1810 template <typename U, size_t otherCapacity, typename OtherAllocator> |
1811 inline void Vector<T, inlineCapacity, Allocator>::prependVector( | 1811 inline void Vector<T, inlineCapacity, Allocator>::prependVector( |
1812 const Vector<U, otherCapacity, OtherAllocator>& val) { | 1812 const Vector<U, otherCapacity, OtherAllocator>& val) { |
1813 insert(0, val.begin(), val.size()); | 1813 insert(0, val.begin(), val.size()); |
1814 } | 1814 } |
1815 | 1815 |
1816 template <typename T, size_t inlineCapacity, typename Allocator> | 1816 template <typename T, size_t inlineCapacity, typename Allocator> |
1817 inline void Vector<T, inlineCapacity, Allocator>::remove(size_t position) { | 1817 inline void Vector<T, inlineCapacity, Allocator>::erase(size_t position) { |
1818 RELEASE_ASSERT(position < size()); | 1818 RELEASE_ASSERT(position < size()); |
1819 T* spot = begin() + position; | 1819 T* spot = begin() + position; |
1820 spot->~T(); | 1820 spot->~T(); |
1821 TypeOperations::moveOverlapping(spot + 1, end(), spot); | 1821 TypeOperations::moveOverlapping(spot + 1, end(), spot); |
1822 clearUnusedSlots(end() - 1, end()); | 1822 clearUnusedSlots(end() - 1, end()); |
1823 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - 1); | 1823 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - 1); |
1824 --m_size; | 1824 --m_size; |
1825 } | 1825 } |
1826 | 1826 |
1827 template <typename T, size_t inlineCapacity, typename Allocator> | 1827 template <typename T, size_t inlineCapacity, typename Allocator> |
1828 inline void Vector<T, inlineCapacity, Allocator>::remove(size_t position, | 1828 inline void Vector<T, inlineCapacity, Allocator>::erase(size_t position, |
1829 size_t length) { | 1829 size_t length) { |
1830 SECURITY_DCHECK(position <= size()); | 1830 SECURITY_DCHECK(position <= size()); |
1831 if (!length) | 1831 if (!length) |
1832 return; | 1832 return; |
1833 RELEASE_ASSERT(position + length <= size()); | 1833 RELEASE_ASSERT(position + length <= size()); |
1834 T* beginSpot = begin() + position; | 1834 T* beginSpot = begin() + position; |
1835 T* endSpot = beginSpot + length; | 1835 T* endSpot = beginSpot + length; |
1836 TypeOperations::destruct(beginSpot, endSpot); | 1836 TypeOperations::destruct(beginSpot, endSpot); |
1837 TypeOperations::moveOverlapping(endSpot, end(), beginSpot); | 1837 TypeOperations::moveOverlapping(endSpot, end(), beginSpot); |
1838 clearUnusedSlots(end() - length, end()); | 1838 clearUnusedSlots(end() - length, end()); |
1839 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - length); | 1839 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size - length); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 visitor, *const_cast<T*>(bufferEntry)); | 1901 visitor, *const_cast<T*>(bufferEntry)); |
1902 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1902 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
1903 } | 1903 } |
1904 } | 1904 } |
1905 | 1905 |
1906 } // namespace WTF | 1906 } // namespace WTF |
1907 | 1907 |
1908 using WTF::Vector; | 1908 using WTF::Vector; |
1909 | 1909 |
1910 #endif // WTF_Vector_h | 1910 #endif // WTF_Vector_h |
OLD | NEW |