sourcehook/sh_vector.h
changeset 204 e6cfa97ef258
parent 154 083cb82d97df
child 294 0d87bc8606f8
     1.1 --- a/sourcehook/sh_vector.h	Tue May 16 22:53:54 2006 +0000
     1.2 +++ b/sourcehook/sh_vector.h	Fri May 19 13:57:04 2006 +0000
     1.3 @@ -277,7 +277,8 @@
     1.4  	CVector & operator =(const CVector<T> & other)
     1.5  	{
     1.6  		clear();
     1.7 -		resize(other.size());
     1.8 +		ChangeSize(other.size());
     1.9 +		m_CurrentUsedSize = other.size();
    1.10  		for (size_t i=0; i<other.size(); i++)
    1.11  			m_Data[i] = other.at(i);
    1.12  		return *this;
    1.13 @@ -342,8 +343,15 @@
    1.14  
    1.15  	bool resize(size_t newSize)
    1.16  	{
    1.17 +		return resize(newSize, T());
    1.18 +	}
    1.19 +
    1.20 +	bool resize(size_t newSize, T defval)
    1.21 +	{
    1.22  		if (!ChangeSize(newSize))
    1.23  			return false;
    1.24 +		for (size_t i = m_CurrentUsedSize; i < newSize; ++i)
    1.25 +			m_Data[i] = defval;
    1.26  		m_CurrentUsedSize = newSize;
    1.27  		return true;
    1.28  	}