Ver código fonte

core: add Last() and Pop() methods to the Array class.

legacy
Sam Hocevar sam 14 anos atrás
pai
commit
8954a123aa
1 arquivos alterados com 15 adições e 0 exclusões
  1. +15
    -0
      src/array.h

+ 15
- 0
src/array.h Ver arquivo

@@ -97,6 +97,16 @@ public:
return m_data[n]; 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<T> const& operator<<(T const &x) inline ArrayBase<T> const& operator<<(T const &x)
{ {
if (m_count >= m_reserved) if (m_count >= m_reserved)
@@ -117,6 +127,11 @@ public:
*this << x; *this << x;
} }


inline void Pop()
{
Remove(m_count - 1, 1);
}

void Remove(int pos, int todelete = 1) void Remove(int pos, int todelete = 1)
{ {
for (int i = pos; i + todelete < m_count; i++) for (int i = pos; i + todelete < m_count; i++)


Carregando…
Cancelar
Salvar