From 8954a123aab2edb946be65ab751ef352d48b93fc Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 1 May 2012 21:19:58 +0000 Subject: [PATCH] core: add Last() and Pop() methods to the Array class. --- src/array.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/array.h b/src/array.h index fad23ea5..b66fd659 100644 --- a/src/array.h +++ b/src/array.h @@ -97,6 +97,16 @@ public: return m_data[n]; } + inline Element& Last() + { + return m_data[m_count - 1]; + } + + inline Element const& Last() const + { + return m_data[m_count - 1]; + } + inline ArrayBase const& operator<<(T const &x) { if (m_count >= m_reserved) @@ -117,6 +127,11 @@ public: *this << x; } + inline void Pop() + { + Remove(m_count - 1, 1); + } + void Remove(int pos, int todelete = 1) { for (int i = pos; i + todelete < m_count; i++)