--------------------- PatchSet 2105 Date: 2005/11/03 21:38:33 Author: dwsquid Branch: squid3-icap Tag: (none) Log: Added "shift" method (as from Perl) for Array class Members: include/Array.h:1.12.2.1->1.12.2.2 Index: squid3/include/Array.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/include/Array.h,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -r1.12.2.1 -r1.12.2.2 --- squid3/include/Array.h 26 Aug 2005 19:09:53 -0000 1.12.2.1 +++ squid3/include/Array.h 3 Nov 2005 21:38:33 -0000 1.12.2.2 @@ -1,5 +1,5 @@ /* - * $Id: Array.h,v 1.12.2.1 2005/08/26 19:09:53 dwsquid Exp $ + * $Id: Array.h,v 1.12.2.2 2005/11/03 21:38:33 dwsquid Exp $ * * AUTHOR: Alex Rousskov * @@ -93,9 +93,11 @@ void reserve (size_t capacity); void push_back (E); Vector &operator += (E item) {push_back(item); return *this;}; + void insert (E); E &back(); E pop_back(); + E shift(); // aka pop_front void preAppend(int app_count); bool empty() const; size_t size() const; @@ -199,15 +201,32 @@ reserve (size() + 1); int i; + for (i = count; i > 0; i--) items[i] = items[i - 1]; items[i] = obj; + count += 1; } template E +Vector::shift() +{ + assert (size()); + value_type result = items[0]; + + for (unsigned int i = 1; i < count; i++) + items[i-1] = items[i]; + + count--; + + return result; +} + +template +E Vector::pop_back() { assert (size());