diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2014-07-22 16:39:01 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2014-07-22 16:39:01 +0000 |
| commit | 21a4337dc2f969dc3ec81e6ba3170119bcb67016 (patch) | |
| tree | af8077ea0e89ec29b499e46583f3de35d1b3103c /src/stable/array.h | |
| parent | 6482ec1f7550f0fca153bd8f556327902c7afec8 (diff) | |
| download | libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.gz libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.bz2 libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.xz libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.zip | |
Deferred erase now works on cache entries. You can erase a cache entry while
it still has active references, and it will be safely cleaned up when the last
reference is released.
Diffstat (limited to '')
| -rw-r--r-- | src/stable/array.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/stable/array.h b/src/stable/array.h index a598865..a662705 100644 --- a/src/stable/array.h +++ b/src/stable/array.h | |||
| @@ -297,6 +297,30 @@ namespace Bu | |||
| 297 | return core->iSize; | 297 | return core->iSize; |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | void setSize( long iNewLen, const value &initTo=value() ) | ||
| 301 | { | ||
| 302 | if( core->iSize == iNewLen ) | ||
| 303 | return; | ||
| 304 | |||
| 305 | _hardCopy(); | ||
| 306 | if( iNewLen > core->iCapacity ) | ||
| 307 | { | ||
| 308 | core->setCapacity( iNewLen ); | ||
| 309 | for( int j = core->iSize; j < iNewLen; j++ ) | ||
| 310 | { | ||
| 311 | core->va.construct( | ||
| 312 | &core->pData[j], | ||
| 313 | initTo | ||
| 314 | ); | ||
| 315 | } | ||
| 316 | core->iSize = iNewLen; | ||
| 317 | } | ||
| 318 | else | ||
| 319 | { | ||
| 320 | core->iSize = iNewLen; | ||
| 321 | } | ||
| 322 | } | ||
| 323 | |||
| 300 | /** | 324 | /** |
| 301 | * Get the capacity of the array. This number will grow as data is | 325 | * Get the capacity of the array. This number will grow as data is |
| 302 | * added, and is mainly for the curious, it doesn't really determine | 326 | * added, and is mainly for the curious, it doesn't really determine |
