wxVector() : m_size(0), m_capacity(0), m_values(NULL) {}
wxVector(size_type size)
- : m_size(0), m_capacity(0), m_values(NULL)
+ : m_size(0), m_capacity(0), m_values(NULL)
{
reserve(size);
for ( size_t n = 0; n < size; n++ )
}
wxVector(size_type size, const value_type& v)
- : m_size(0), m_capacity(0), m_values(NULL)
+ : m_size(0), m_capacity(0), m_values(NULL)
{
reserve(size);
for ( size_t n = 0; n < size; n++ )
m_capacity = n;
}
+ void resize(size_type n)
+ {
+ if ( n < m_size )
+ Shrink(n);
+ else if ( n > m_size )
+ Extend(n, value_type());
+ }
+
+ void resize(size_type n, const value_type& v)
+ {
+ if ( n < m_size )
+ Shrink(n);
+ else if ( n > m_size )
+ Extend(n, v);
+ }
+
size_type size() const
{
return m_size;
}
private:
+ void Shrink(size_type n)
+ {
+ for ( size_type i = n; i < m_size; i++ )
+ m_values[i].~T();
+ m_size = n;
+ }
+
+ void Extend(size_type n, const value_type& v)
+ {
+ reserve(n);
+ for ( size_type i = m_size; i < n; i++ )
+ push_back(v);
+ }
+
size_type m_size,
m_capacity;
value_type *m_values;