projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix multiple problems with selection in controls with wxTR_MULTIPLE style (closes...
[wxWidgets.git]
/
include
/
wx
/
vector.h
diff --git
a/include/wx/vector.h
b/include/wx/vector.h
index 056202bcaa32840c0c4090c227a44d3d910f5bfa..ab07ca0f4a8c1eb0f7c8f955e5db0fbca4d5f587 100644
(file)
--- a/
include/wx/vector.h
+++ b/
include/wx/vector.h
@@
-170,7
+170,7
@@
public:
wxVector() : m_size(0), m_capacity(0), m_values(NULL) {}
wxVector(size_type size)
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++ )
{
reserve(size);
for ( size_t n = 0; n < size; n++ )
@@
-178,7
+178,7
@@
public:
}
wxVector(size_type size, const value_type& v)
}
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++ )
{
reserve(size);
for ( size_t n = 0; n < size; n++ )
@@
-229,6
+229,22
@@
public:
m_capacity = 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;
size_type size() const
{
return m_size;
@@
-386,6
+402,20
@@
private:
}
private:
}
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;
size_type m_size,
m_capacity;
value_type *m_values;