From 21a4337dc2f969dc3ec81e6ba3170119bcb67016 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 22 Jul 2014 16:39:01 +0000 Subject: 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. --- src/stable/array.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/stable/array.h') 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 return core->iSize; } + void setSize( long iNewLen, const value &initTo=value() ) + { + if( core->iSize == iNewLen ) + return; + + _hardCopy(); + if( iNewLen > core->iCapacity ) + { + core->setCapacity( iNewLen ); + for( int j = core->iSize; j < iNewLen; j++ ) + { + core->va.construct( + &core->pData[j], + initTo + ); + } + core->iSize = iNewLen; + } + else + { + core->iSize = iNewLen; + } + } + /** * Get the capacity of the array. This number will grow as data is * added, and is mainly for the curious, it doesn't really determine -- cgit v1.2.3