1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added new method Array::remove that takes an element pointer.

This commit is contained in:
jules 2015-12-10 10:35:30 +00:00
parent 6faa33cfbd
commit c334530f29

View file

@ -812,6 +812,28 @@ public:
return ElementType();
}
/** Removes an element from the array.
This will remove the element pointed to by the given iterator,
and move back all the subsequent elements to close the gap.
If the iterator passed in does not point to an element within the
array, behaviour is undefined.
@param elementToRemove a pointer to the element to remove
@see removeFirstMatchingValue, removeAllInstancesOf, removeRange
*/
void remove (const ElementType* elementToRemove)
{
jassert (elementToRemove != nullptr);
const ScopedLockType lock (getLock());
jassert (data.elements != nullptr);
const int indexToRemove = int (elementToRemove - data.elements);
jassert (isPositiveAndBelow (indexToRemove, numUsed));
removeInternal (indexToRemove);
}
/** Removes an item from the array.
This will remove the first occurrence of the given element from the array.