Index: cc/quads/list_container.cc |
diff --git a/cc/quads/list_container.cc b/cc/quads/list_container.cc |
index 5d092a113e8502e9c34286a1a326ae8b672028e3..b1501c0de862d50c4164849daa18a1709fcf32b7 100644 |
--- a/cc/quads/list_container.cc |
+++ b/cc/quads/list_container.cc |
@@ -68,6 +68,7 @@ class ListContainer<BaseElementType>::ListContainerCharAllocator { |
char* Begin() const { return data.get(); } |
char* End() const { return data.get() + size * step; } |
char* LastElement() const { return data.get() + (size - 1) * step; } |
+ char* ElementAt(size_t index) const { return data.get() + index * step; } |
private: |
DISALLOW_COPY_AND_ASSIGN(InnerList); |
@@ -373,6 +374,37 @@ const BaseElementType* ListContainer<BaseElementType>::back() const { |
} |
template <typename BaseElementType> |
+const BaseElementType* ListContainer<BaseElementType>::ElementAt( |
+ size_t index) const { |
+ DCHECK_LT(index, size()); |
+ size_t list_index; |
+ for (list_index = 0; list_index < data_->list_count(); ++list_index) { |
+ size_t current_size = data_->InnerListById(list_index)->size; |
+ if (index < current_size) |
+ break; |
+ index -= current_size; |
+ } |
+ return &*ConstIterator(data_.get(), |
+ list_index, |
+ data_->InnerListById(list_index)->ElementAt(index)); |
+} |
+ |
+template <typename BaseElementType> |
+BaseElementType* ListContainer<BaseElementType>::ElementAt(size_t index) { |
+ DCHECK_LT(index, size()); |
+ size_t list_index; |
+ for (list_index = 0; list_index < data_->list_count(); ++list_index) { |
+ size_t current_size = data_->InnerListById(list_index)->size; |
+ if (index < current_size) |
+ break; |
+ index -= current_size; |
+ } |
+ return &*Iterator(data_.get(), |
+ list_index, |
+ data_->InnerListById(list_index)->ElementAt(index)); |
+} |
+ |
+template <typename BaseElementType> |
BaseElementType* ListContainer<BaseElementType>::Allocate( |
size_t size_of_actual_element_in_bytes) { |
DCHECK_LE(size_of_actual_element_in_bytes, data_->element_size()); |