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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 if (size() * 2 < capacity()) | 741 if (size() * 2 < capacity()) |
742 shrinkCapacity(size() + size() / 4 + 1); | 742 shrinkCapacity(size() + size() / 4 + 1); |
743 } | 743 } |
744 | 744 |
745 void clear() { shrinkCapacity(0); } | 745 void clear() { shrinkCapacity(0); } |
746 | 746 |
747 template <typename U> void append(const U*, size_t); | 747 template <typename U> void append(const U*, size_t); |
748 template <typename U> void append(const U&); | 748 template <typename U> void append(const U&); |
749 template <typename U> void uncheckedAppend(const U& val); | 749 template <typename U> void uncheckedAppend(const U& val); |
750 template <typename U, size_t otherCapacity, typename V> void appendVector(co
nst Vector<U, otherCapacity, V>&); | 750 template <typename U, size_t otherCapacity, typename V> void appendVector(co
nst Vector<U, otherCapacity, V>&); |
| 751 T* appendUninitialized(size_t); |
751 | 752 |
752 template <typename U> void insert(size_t position, const U*, size_t); | 753 template <typename U> void insert(size_t position, const U*, size_t); |
753 template <typename U> void insert(size_t position, const U&); | 754 template <typename U> void insert(size_t position, const U&); |
754 template <typename U, size_t c, typename V> void insert(size_t position, con
st Vector<U, c, V>&); | 755 template <typename U, size_t c, typename V> void insert(size_t position, con
st Vector<U, c, V>&); |
755 | 756 |
756 template <typename U> void prepend(const U*, size_t); | 757 template <typename U> void prepend(const U*, size_t); |
757 template <typename U> void prepend(const U&); | 758 template <typename U> void prepend(const U&); |
758 template <typename U, size_t c, typename V> void prepend(const Vector<U, c,
V>&); | 759 template <typename U, size_t c, typename V> void prepend(const Vector<U, c,
V>&); |
759 | 760 |
760 void remove(size_t position); | 761 void remove(size_t position); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 } | 1188 } |
1188 | 1189 |
1189 template <typename T, size_t inlineCapacity, typename Allocator> | 1190 template <typename T, size_t inlineCapacity, typename Allocator> |
1190 template <typename U, size_t otherCapacity, typename OtherAllocator> | 1191 template <typename U, size_t otherCapacity, typename OtherAllocator> |
1191 inline void Vector<T, inlineCapacity, Allocator>::appendVector(const Vector<U, o
therCapacity, OtherAllocator>& val) | 1192 inline void Vector<T, inlineCapacity, Allocator>::appendVector(const Vector<U, o
therCapacity, OtherAllocator>& val) |
1192 { | 1193 { |
1193 append(val.begin(), val.size()); | 1194 append(val.begin(), val.size()); |
1194 } | 1195 } |
1195 | 1196 |
1196 template <typename T, size_t inlineCapacity, typename Allocator> | 1197 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1198 T* Vector<T, inlineCapacity, Allocator>::appendUninitialized(size_t dataSize) |
| 1199 { |
| 1200 ASSERT(Allocator::isAllocationAllowed()); |
| 1201 size_t newSize = m_size + dataSize; |
| 1202 if (newSize > capacity()) { |
| 1203 expandCapacity(newSize); |
| 1204 ASSERT(begin()); |
| 1205 } |
| 1206 RELEASE_ASSERT(newSize >= m_size); |
| 1207 T* dest = end(); |
| 1208 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, newSize); |
| 1209 m_size = newSize; |
| 1210 return dest; |
| 1211 } |
| 1212 |
| 1213 template <typename T, size_t inlineCapacity, typename Allocator> |
1197 template <typename U> | 1214 template <typename U> |
1198 void Vector<T, inlineCapacity, Allocator>::insert(size_t position, const U* data
, size_t dataSize) | 1215 void Vector<T, inlineCapacity, Allocator>::insert(size_t position, const U* data
, size_t dataSize) |
1199 { | 1216 { |
1200 ASSERT(Allocator::isAllocationAllowed()); | 1217 ASSERT(Allocator::isAllocationAllowed()); |
1201 RELEASE_ASSERT(position <= size()); | 1218 RELEASE_ASSERT(position <= size()); |
1202 size_t newSize = m_size + dataSize; | 1219 size_t newSize = m_size + dataSize; |
1203 if (newSize > capacity()) { | 1220 if (newSize > capacity()) { |
1204 data = expandCapacity(newSize, data); | 1221 data = expandCapacity(newSize, data); |
1205 ASSERT(begin()); | 1222 ASSERT(begin()); |
1206 } | 1223 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 struct NeedsTracing<Vector<T, N>> { | 1364 struct NeedsTracing<Vector<T, N>> { |
1348 static const bool value = false; | 1365 static const bool value = false; |
1349 }; | 1366 }; |
1350 #endif | 1367 #endif |
1351 | 1368 |
1352 } // namespace WTF | 1369 } // namespace WTF |
1353 | 1370 |
1354 using WTF::Vector; | 1371 using WTF::Vector; |
1355 | 1372 |
1356 #endif // WTF_Vector_h | 1373 #endif // WTF_Vector_h |
OLD | NEW |