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

Unified Diff: src/list-inl.h

Issue 40105: Add an insert function to our list utility class. (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 | « src/list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/list-inl.h
===================================================================
--- src/list-inl.h (revision 1407)
+++ src/list-inl.h (working copy)
@@ -59,6 +59,18 @@
template<typename T, class P>
+T& List<T, P>::Insert(int i, const T& element) {
+ int free_index = length_ - 1;
+ Add(last()); // Add grows the list if necessary.
+ while (free_index > i) {
+ data_[free_index] = data_[free_index - 1];
+ free_index--;
+ }
+ data_[free_index] = element;
+}
+
+
+template<typename T, class P>
T List<T, P>::Remove(int i) {
T element = at(i);
length_--;
« no previous file with comments | « src/list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698