Update some beast container code

This commit is contained in:
Vinnie Falco
2013-07-01 14:44:00 -07:00
parent 10a0db9160
commit 485d048415
3 changed files with 29 additions and 66 deletions

View File

@@ -288,7 +288,7 @@ public:
@param newObject the new object to add to the array
@see set, insert, addIfNotAlreadyThere, addSorted, addArray
*/
void add (ObjectClass* const newObject) noexcept
ObjectClass* add (ObjectClass* const newObject) noexcept
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1);
@@ -297,6 +297,8 @@ public:
if (newObject != nullptr)
newObject->incReferenceCount();
return newObject;
}
/** Inserts a new object into the array at the given index.
@@ -312,8 +314,8 @@ public:
@param newObject the new object to add to the array
@see add, addSorted, addIfNotAlreadyThere, set
*/
void insert (int indexToInsertAt,
ObjectClass* const newObject) noexcept
ObjectClass* insert (int indexToInsertAt,
ObjectClass* const newObject) noexcept
{
if (indexToInsertAt >= 0)
{
@@ -337,10 +339,12 @@ public:
newObject->incReferenceCount();
++numUsed;
return newObject;
}
else
{
add (newObject);
return add (newObject);
}
}
@@ -617,8 +621,8 @@ public:
{
const ScopedLockType lock (getLock());
const int start = blimit (0, numUsed, startIndex);
const int endIndex = blimit (0, numUsed, startIndex + numberToRemove);
const int start = jlimit (0, numUsed, startIndex);
const int endIndex = jlimit (0, numUsed, startIndex + numberToRemove);
if (endIndex > start)
{
@@ -847,11 +851,11 @@ public:
/** Returns the type of scoped lock to use for locking this array */
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;
int numUsed;
};
#endif // BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
#endif