[Scummvm-cvs-logs] SF.net SVN: scummvm: [30983] scummvm/trunk/common/array.h
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Feb 27 15:06:07 CET 2008
Revision: 30983
http://scummvm.svn.sourceforge.net/scummvm/?rev=30983&view=rev
Author: fingolfin
Date: 2008-02-27 06:06:06 -0800 (Wed, 27 Feb 2008)
Log Message:
-----------
Added Array::resize() method
Modified Paths:
--------------
scummvm/trunk/common/array.h
Modified: scummvm/trunk/common/array.h
===================================================================
--- scummvm/trunk/common/array.h 2008-02-27 13:35:29 UTC (rev 30982)
+++ scummvm/trunk/common/array.h 2008-02-27 14:06:06 UTC (rev 30983)
@@ -159,6 +159,22 @@
}
}
+ 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)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list