Generalize swapWithArray

Conflicts:
	Subtrees/beast/TODO.txt
This commit is contained in:
Vinnie Falco committed 2013-07-27 11:00:21 -07:00
1 parent 810954014b
commit 7266111b68
5 files changed
+33 -11

No files matched your search

+3 -2
View File
@@ -571,10 +571,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (Array& otherArray) noexcept
template <class OtherArrayType>
void swapWithArray (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
@@ -90,7 +90,7 @@ public:
//==============================================================================
/** Clears the array, optionally deleting the objects inside it first. */
void clear (const bool deleteObjects = true)
void clear (bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
@@ -101,14 +101,19 @@ public:
numUsed = 0;
}
/** Removes all elements from the array without freeing the array's allocated storage.
/** Clears the array, optionally deleting the objects inside it first.
The array's allocated storage is preserved.
@see clear
*/
void clearQuick()
void clearQuick(bool deleteObjects = true)
{
const ScopedLockType lock (getLock());
deleteAllElements();
if (deleteObjects)
deleteAllObjects();
numUsed = 0;
}
@@ -21,8 +21,8 @@
*/
//==============================================================================
#ifndef BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
#define BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
#ifndef BEAST_SHAREDOBJECTARRAY_H_INCLUDED
#define BEAST_SHAREDOBJECTARRAY_H_INCLUDED
#include "../memory/beast_SharedObject.h"
#include "beast_ArrayAllocationBase.h"
@@ -740,10 +740,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (SharedObjectArray& otherArray) noexcept
template <class OtherArrayType>
void swapWithArray (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);