diff options
Diffstat (limited to 'src/stable/array.h')
-rw-r--r-- | src/stable/array.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/stable/array.h b/src/stable/array.h index ecffc6a..b089bda 100644 --- a/src/stable/array.h +++ b/src/stable/array.h | |||
@@ -297,7 +297,7 @@ namespace Bu | |||
297 | return core->iSize; | 297 | return core->iSize; |
298 | } | 298 | } |
299 | 299 | ||
300 | void setSize( long iNewLen, const value &initTo=value() ) | 300 | void setSize( long iNewLen ) |
301 | { | 301 | { |
302 | if( core->iSize == iNewLen ) | 302 | if( core->iSize == iNewLen ) |
303 | return; | 303 | return; |
@@ -306,19 +306,40 @@ namespace Bu | |||
306 | if( iNewLen > core->iCapacity ) | 306 | if( iNewLen > core->iCapacity ) |
307 | { | 307 | { |
308 | core->setCapacity( iNewLen ); | 308 | core->setCapacity( iNewLen ); |
309 | } | ||
310 | if( iNewLen > core->iSize ) | ||
311 | { | ||
309 | for( int j = core->iSize; j < iNewLen; j++ ) | 312 | for( int j = core->iSize; j < iNewLen; j++ ) |
310 | { | 313 | { |
311 | core->va.construct( | 314 | core->va.construct( |
312 | &core->pData[j], | 315 | &core->pData[j] |
313 | initTo | ||
314 | ); | 316 | ); |
315 | } | 317 | } |
316 | core->iSize = iNewLen; | ||
317 | } | 318 | } |
318 | else | 319 | core->iSize = iNewLen; |
320 | } | ||
321 | |||
322 | void setSize( long iNewLen, const value &initTo ) | ||
323 | { | ||
324 | if( core->iSize == iNewLen ) | ||
325 | return; | ||
326 | |||
327 | _hardCopy(); | ||
328 | if( iNewLen > core->iCapacity ) | ||
329 | { | ||
330 | core->setCapacity( iNewLen ); | ||
331 | } | ||
332 | if( iNewLen > core->iSize ) | ||
319 | { | 333 | { |
320 | core->iSize = iNewLen; | 334 | for( int j = core->iSize; j < iNewLen; j++ ) |
335 | { | ||
336 | core->va.construct( | ||
337 | &core->pData[j], | ||
338 | initTo | ||
339 | ); | ||
340 | } | ||
321 | } | 341 | } |
342 | core->iSize = iNewLen; | ||
322 | } | 343 | } |
323 | 344 | ||
324 | /** | 345 | /** |