mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-17 00:44:19 +00:00
Changed the Array::remove() method to return void, and added an Array::removeAndReturn() method to replace the old functionality
This commit is contained in:
parent
dd245effd2
commit
b439452edd
5 changed files with 29 additions and 10 deletions
|
|
@ -333,7 +333,7 @@ OpenDocumentManager::Document* RecentDocumentList::getPrevious()
|
|||
if (! canGoToPrevious())
|
||||
return nullptr;
|
||||
|
||||
nextDocs.insert (0, previousDocs.remove (previousDocs.size() - 1));
|
||||
nextDocs.insert (0, previousDocs.removeAndReturn (previousDocs.size() - 1));
|
||||
return previousDocs.getLast();
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +342,7 @@ OpenDocumentManager::Document* RecentDocumentList::getNext()
|
|||
if (! canGoToNext())
|
||||
return nullptr;
|
||||
|
||||
OpenDocumentManager::Document* d = nextDocs.remove (0);
|
||||
OpenDocumentManager::Document* d = nextDocs.removeAndReturn (0);
|
||||
previousDocs.add (d);
|
||||
return d;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -791,6 +791,26 @@ public:
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
/** Removes an element from the array.
|
||||
|
||||
This will remove the element at a given index, and move back
|
||||
all the subsequent elements to close the gap.
|
||||
If the index passed in is out-of-range, nothing will happen.
|
||||
|
||||
@param indexToRemove the index of the element to remove
|
||||
@see removeAndReturn, removeFirstMatchingValue, removeAllInstancesOf, removeRange
|
||||
*/
|
||||
void remove (int indexToRemove)
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
|
||||
if (isPositiveAndBelow (indexToRemove, numUsed))
|
||||
{
|
||||
jassert (data.elements != nullptr);
|
||||
removeInternal (indexToRemove);
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes an element from the array.
|
||||
|
||||
This will remove the element at a given index, and move back
|
||||
|
|
@ -801,7 +821,7 @@ public:
|
|||
@returns the element that has been removed
|
||||
@see removeFirstMatchingValue, removeAllInstancesOf, removeRange
|
||||
*/
|
||||
ElementType remove (const int indexToRemove)
|
||||
ElementType removeAndReturn (const int indexToRemove)
|
||||
{
|
||||
const ScopedLockType lock (getLock());
|
||||
|
||||
|
|
|
|||
|
|
@ -292,10 +292,9 @@ public:
|
|||
/** A dummy bail-out checker that always returns false.
|
||||
See the ListenerList notes for more info about bail-out checkers.
|
||||
*/
|
||||
class DummyBailOutChecker
|
||||
struct DummyBailOutChecker
|
||||
{
|
||||
public:
|
||||
inline bool shouldBailOut() const noexcept { return false; }
|
||||
bool shouldBailOut() const noexcept { return false; }
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
for (int i = selectedItems.size(); --i >= 0;)
|
||||
if (! other.isSelected (selectedItems.getReference (i)))
|
||||
itemDeselected (selectedItems.remove (i));
|
||||
itemDeselected (selectedItems.removeAndReturn (i));
|
||||
|
||||
for (SelectableItemType* i = other.selectedItems.begin(), *e = other.selectedItems.end(); i != e; ++i)
|
||||
{
|
||||
|
|
@ -235,7 +235,7 @@ public:
|
|||
if (i >= 0)
|
||||
{
|
||||
changed();
|
||||
itemDeselected (selectedItems.remove (i));
|
||||
itemDeselected (selectedItems.removeAndReturn (i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ public:
|
|||
|
||||
for (int i = selectedItems.size(); --i >= 0;)
|
||||
{
|
||||
itemDeselected (selectedItems.remove (i));
|
||||
itemDeselected (selectedItems.removeAndReturn (i));
|
||||
i = jmin (i, selectedItems.size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public:
|
|||
if (ToolbarItemComponent* const tc = dynamic_cast<ToolbarItemComponent*> (getChildComponent (i)))
|
||||
{
|
||||
tc->setVisible (false);
|
||||
const int index = oldIndexes.remove (i);
|
||||
const int index = oldIndexes.removeAndReturn (i);
|
||||
owner->addChildComponent (tc, index);
|
||||
--i;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue