From 9fde3802309b686ce66ced147fd5b893049813d6 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 28 Jul 2013 01:56:32 -0700 Subject: [PATCH] Return index in Array::add() --- .../beast/modules/beast_core/containers/beast_Array.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Subtrees/beast/modules/beast_core/containers/beast_Array.h b/Subtrees/beast/modules/beast_core/containers/beast_Array.h index 07ab7bdfb9..74f800068a 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_Array.h +++ b/Subtrees/beast/modules/beast_core/containers/beast_Array.h @@ -364,13 +364,15 @@ public: /** Appends a new element at the end of the array. @param newElement the new object to add to the array + @return The index of the new item, or -1 if it already existed. @see set, insert, addIfNotAlreadyThere, addSorted, addUsingDefaultSort, addArray */ - void add (ParameterType newElement) + int add (ParameterType newElement) { const ScopedLockType lock (getLock()); data.ensureAllocatedSize (numUsed + 1); new (data.elements + numUsed++) ElementType (newElement); + return numUsed; } /** Inserts a new element into the array at a given position. @@ -494,13 +496,16 @@ public: will be done. @param newElement the new object to add to the array + @return The index of the new item, or -1 if it already existed. */ - void addIfNotAlreadyThere (ParameterType newElement) + int addIfNotAlreadyThere (ParameterType newElement) { const ScopedLockType lock (getLock()); if (! contains (newElement)) - add (newElement); + return add (newElement); + + return -1; } /** Replaces an element with a new value.