Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: src/list.h

Issue 39148: In List::Add, correctly handle the case of adding a reference to a... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/list-inl.h » ('j') | src/list-inl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/list.h
===================================================================
--- src/list.h (revision 1421)
+++ src/list.h (working copy)
@@ -53,13 +53,15 @@
INLINE(void* operator new(size_t size)) { return P::New(size); }
INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); }
+ // Returns a reference to the element at index i. This reference is
+ // not safe to use after operations that can change the list's
+ // backing store (eg, Add).
inline T& operator[](int i) const {
ASSERT(0 <= i && i < length_);
return data_[i];
}
inline T& at(int i) const { return operator[](i); }
inline T& last() const {
- ASSERT(!is_empty());
return at(length_ - 1);
}
@@ -72,19 +74,13 @@
// Adds a copy of the given 'element' to the end of the list,
// expanding the list if necessary.
- T& Add(const T& element);
+ void Add(const T& element);
// Added 'count' elements with the value 'value' and returns a
// vector that allows access to the elements. The vector is valid
// until the next change is made to this list.
- Vector<T> AddBlock(const T& value, int count);
+ Vector<T> AddBlock(T value, int count);
- // Inserts a copy of the given element at index i in the list. All
- // elements formerly at or above i are moved up and the length of
- // the list increases by one. This function's complexity is linear
- // in the size of the list.
- T& Insert(int i, const T& element);
-
// Removes the i'th element without deleting it even if T is a
// pointer type; moves all elements above i "down". Returns the
// removed element. This function's complexity is linear in the
« no previous file with comments | « no previous file | src/list-inl.h » ('j') | src/list-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698