Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 size_t capacityInBytes() const; | 52 size_t capacityInBytes() const; |
| 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 void removeEmptyBuffers(); | |
|
jbroman
2016/07/06 19:09:37
Mind a comment clarifying the intended use of this
Xianzhu
2016/07/06 19:29:34
Done.
| |
| 62 | 63 |
| 63 Vector<void*> m_elements; | 64 Vector<void*> m_elements; |
| 64 | 65 |
| 65 private: | 66 private: |
| 66 class Buffer; | 67 class Buffer; |
| 67 | 68 |
| 68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); | 69 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); |
| 69 | 70 |
| 70 Vector<std::unique_ptr<Buffer>> m_buffers; | 71 Vector<std::unique_ptr<Buffer>> m_buffers; |
| 71 unsigned m_endIndex; | 72 unsigned m_endIndex; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 | 136 |
| 136 ContiguousContainerBase::operator=(std::move(source)); | 137 ContiguousContainerBase::operator=(std::move(source)); |
| 137 return *this; | 138 return *this; |
| 138 } | 139 } |
| 139 | 140 |
| 140 using ContiguousContainerBase::size; | 141 using ContiguousContainerBase::size; |
| 141 using ContiguousContainerBase::isEmpty; | 142 using ContiguousContainerBase::isEmpty; |
| 142 using ContiguousContainerBase::capacityInBytes; | 143 using ContiguousContainerBase::capacityInBytes; |
| 143 using ContiguousContainerBase::usedCapacityInBytes; | 144 using ContiguousContainerBase::usedCapacityInBytes; |
| 144 using ContiguousContainerBase::memoryUsageInBytes; | 145 using ContiguousContainerBase::memoryUsageInBytes; |
| 146 using ContiguousContainerBase::removeEmptyBuffers; | |
| 145 | 147 |
| 146 iterator begin() { return iterator(m_elements.begin()); } | 148 iterator begin() { return iterator(m_elements.begin()); } |
| 147 iterator end() { return iterator(m_elements.end()); } | 149 iterator end() { return iterator(m_elements.end()); } |
| 148 const_iterator begin() const { return const_iterator(m_elements.begin()); } | 150 const_iterator begin() const { return const_iterator(m_elements.begin()); } |
| 149 const_iterator end() const { return const_iterator(m_elements.end()); } | 151 const_iterator end() const { return const_iterator(m_elements.end()); } |
| 150 reverse_iterator rbegin() { return reverse_iterator(m_elements.rbegin()); } | 152 reverse_iterator rbegin() { return reverse_iterator(m_elements.rbegin()); } |
| 151 reverse_iterator rend() { return reverse_iterator(m_elements.rend()); } | 153 reverse_iterator rend() { return reverse_iterator(m_elements.rend()); } |
| 152 const_reverse_iterator rbegin() const { return const_reverse_iterator(m_elem ents.rbegin()); } | 154 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()); } | 155 const_reverse_iterator rend() const { return const_reverse_iterator(m_elemen ts.rend()); } |
| 154 | 156 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 ASSERT(alignedSize % alignment == 0); | 213 ASSERT(alignedSize % alignment == 0); |
| 212 ASSERT(alignedSize >= size); | 214 ASSERT(alignedSize >= size); |
| 213 ASSERT(alignedSize < size + alignment); | 215 ASSERT(alignedSize < size + alignment); |
| 214 return alignedSize; | 216 return alignedSize; |
| 215 } | 217 } |
| 216 }; | 218 }; |
| 217 | 219 |
| 218 } // namespace blink | 220 } // namespace blink |
| 219 | 221 |
| 220 #endif // ContiguousContainer_h | 222 #endif // ContiguousContainer_h |
| OLD | NEW |