mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-04 08:17:40 +00:00
Added Array::resize() method
svn-id: r30983
This commit is contained in:
parent
0a918b02fb
commit
142a39da22
@ -159,6 +159,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void resize(uint newSize) {
|
||||
if (newSize == _size)
|
||||
return;
|
||||
|
||||
T *old_data = _data;
|
||||
_capacity = newSize;
|
||||
_data = new T[newSize];
|
||||
if (old_data) {
|
||||
// Copy old data
|
||||
int cnt = (_size < newSize ? _size : newSize);
|
||||
copy(old_data, old_data + cnt, _data);
|
||||
delete [] old_data;
|
||||
}
|
||||
_size = newSize;
|
||||
}
|
||||
|
||||
protected:
|
||||
void ensureCapacity(uint len) {
|
||||
if (len >= _capacity)
|
||||
|
Loading…
Reference in New Issue
Block a user