]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added a Vector::front() method, to mimic std::vector and other STL containers.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 6 Sep 2011 18:03:10 +0000 (12:03 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 6 Sep 2011 18:03:10 +0000 (12:03 -0600)
include/Array.h

index 17c312a0fb4d5976e107c3e56a33a7fe8bc65856..d54620b9d102c9f7f8dd6ad0ba1a944c1b0792b6 100644 (file)
@@ -97,6 +97,8 @@ public:
     Vector &operator += (E item) {push_back(item); return *this;};
 
     void insert (E);
+    const E &front() const;
+    E &front();
     E &back();
     E pop_back();
     E shift();         // aka pop_front
@@ -250,6 +252,22 @@ Vector<E>::back()
     return items[size() - 1];
 }
 
+template<class E>
+const E &
+Vector<E>::front() const
+{
+    assert (size());
+    return items[0];
+}
+
+template<class E>
+E &
+Vector<E>::front()
+{
+    assert (size());
+    return items[0];
+}
+
 template<class E>
 void
 Vector<E>::prune(E item)