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:
parent
6faa33cfbd
commit
c334530f29
1 changed files with 22 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue