Good idea.  I will mention it.

On Wed, Mar 4, 2009 at 11:26 AM, Erik Corry <[email protected]> wrote:

> It should be part of the documentation in the .h file that this takes
> linear time.  Same for the remove function now you are at it.
>
> LGTM
>
> 2009/3/4  <[email protected]>:
> > Reviewers: Erik Corry,
> >
> > Message:
> > It's not called anywhere yet, but I'll need it.  Order of arguments was
> > chosen to be the same as the STL list insert.
> >
> > Description:
> > Add an insert function to our list utility class.
> >
> > Please review this at http://codereview.chromium.org/40105
> >
> > SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
> >
> > Affected files:
> >  M     src/list-inl.h
> >  M     src/list.h
> >
> >
> > Index: src/list.h
> > ===================================================================
> > --- src/list.h  (revision 1407)
> > +++ src/list.h  (working copy)
> > @@ -79,6 +79,11 @@
> >   // until the next change is made to this list.
> >   Vector<T> AddBlock(const 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.
> > +  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.
> > 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_--;
> >
> >
> >
>
>
>
> --
> Erik Corry, Software Engineer
> Google Denmark ApS.  CVR nr. 28 86 69 84
> c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018
> Copenhagen K, Denmark.
>

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to