OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ContiguousContainer_h | 5 #ifndef ContiguousContainer_h |
6 #define ContiguousContainer_h | 6 #define ContiguousContainer_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "wtf/Alignment.h" | 9 #include "wtf/Alignment.h" |
10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 size_t usedCapacityInBytes() const; | 53 size_t usedCapacityInBytes() const; |
54 size_t memoryUsageInBytes() const; | 54 size_t memoryUsageInBytes() const; |
55 | 55 |
56 // These do not invoke constructors or destructors. | 56 // These do not invoke constructors or destructors. |
57 void reserveInitialCapacity(size_t, const char* typeName); | 57 void reserveInitialCapacity(size_t, const char* typeName); |
58 void* allocate(size_t objectSize, const char* typeName); | 58 void* allocate(size_t objectSize, const char* typeName); |
59 void removeLast(); | 59 void removeLast(); |
60 void clear(); | 60 void clear(); |
61 void swap(ContiguousContainerBase&); | 61 void swap(ContiguousContainerBase&); |
62 | 62 |
63 // Discards excess bufer capacity. Intended for use when no more appending | |
jbroman
2016/07/12 19:05:49
nit: bufer -> buffer
Xianzhu
2016/07/13 00:28:21
Done.
| |
64 // is anticipated. | |
65 void shrinkToFit(); | |
66 | |
63 Vector<void*> m_elements; | 67 Vector<void*> m_elements; |
64 | 68 |
65 private: | 69 private: |
66 class Buffer; | 70 class Buffer; |
67 | 71 |
68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); | 72 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); |
69 | 73 |
70 Vector<std::unique_ptr<Buffer>> m_buffers; | 74 Vector<std::unique_ptr<Buffer>> m_buffers; |
71 unsigned m_endIndex; | 75 unsigned m_endIndex; |
72 size_t m_maxObjectSize; | 76 size_t m_maxObjectSize; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 139 |
136 ContiguousContainerBase::operator=(std::move(source)); | 140 ContiguousContainerBase::operator=(std::move(source)); |
137 return *this; | 141 return *this; |
138 } | 142 } |
139 | 143 |
140 using ContiguousContainerBase::size; | 144 using ContiguousContainerBase::size; |
141 using ContiguousContainerBase::isEmpty; | 145 using ContiguousContainerBase::isEmpty; |
142 using ContiguousContainerBase::capacityInBytes; | 146 using ContiguousContainerBase::capacityInBytes; |
143 using ContiguousContainerBase::usedCapacityInBytes; | 147 using ContiguousContainerBase::usedCapacityInBytes; |
144 using ContiguousContainerBase::memoryUsageInBytes; | 148 using ContiguousContainerBase::memoryUsageInBytes; |
149 using ContiguousContainerBase::shrinkToFit; | |
145 | 150 |
146 iterator begin() { return iterator(m_elements.begin()); } | 151 iterator begin() { return iterator(m_elements.begin()); } |
147 iterator end() { return iterator(m_elements.end()); } | 152 iterator end() { return iterator(m_elements.end()); } |
148 const_iterator begin() const { return const_iterator(m_elements.begin()); } | 153 const_iterator begin() const { return const_iterator(m_elements.begin()); } |
149 const_iterator end() const { return const_iterator(m_elements.end()); } | 154 const_iterator end() const { return const_iterator(m_elements.end()); } |
150 reverse_iterator rbegin() { return reverse_iterator(m_elements.rbegin()); } | 155 reverse_iterator rbegin() { return reverse_iterator(m_elements.rbegin()); } |
151 reverse_iterator rend() { return reverse_iterator(m_elements.rend()); } | 156 reverse_iterator rend() { return reverse_iterator(m_elements.rend()); } |
152 const_reverse_iterator rbegin() const { return const_reverse_iterator(m_elem ents.rbegin()); } | 157 const_reverse_iterator rbegin() const { return const_reverse_iterator(m_elem ents.rbegin()); } |
153 const_reverse_iterator rend() const { return const_reverse_iterator(m_elemen ts.rend()); } | 158 const_reverse_iterator rend() const { return const_reverse_iterator(m_elemen ts.rend()); } |
154 | 159 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 DCHECK_EQ(alignedSize % alignment, 0u); | 217 DCHECK_EQ(alignedSize % alignment, 0u); |
213 DCHECK_GE(alignedSize, size); | 218 DCHECK_GE(alignedSize, size); |
214 DCHECK_LT(alignedSize, size + alignment); | 219 DCHECK_LT(alignedSize, size + alignment); |
215 return alignedSize; | 220 return alignedSize; |
216 } | 221 } |
217 }; | 222 }; |
218 | 223 |
219 } // namespace blink | 224 } // namespace blink |
220 | 225 |
221 #endif // ContiguousContainer_h | 226 #endif // ContiguousContainer_h |
OLD | NEW |