Browse Source

Changed the Array::remove() method to return void, and added an Array::removeAndReturn() method to replace the old functionality

tags/2021-05-28
jules 9 years ago
parent
commit
b439452edd
5 changed files with 29 additions and 10 deletions
  1. +2
    -2
      extras/Projucer/Source/Application/jucer_OpenDocumentManager.cpp
  2. +21
    -1
      modules/juce_core/containers/juce_Array.h
  3. +2
    -3
      modules/juce_core/containers/juce_ListenerList.h
  4. +3
    -3
      modules/juce_gui_basics/mouse/juce_SelectedItemSet.h
  5. +1
    -1
      modules/juce_gui_basics/widgets/juce_Toolbar.cpp

+ 2
- 2
extras/Projucer/Source/Application/jucer_OpenDocumentManager.cpp View File

@@ -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;
}


+ 21
- 1
modules/juce_core/containers/juce_Array.h View File

@@ -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());


+ 2
- 3
modules/juce_core/containers/juce_ListenerList.h View File

@@ -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; }
};
//==============================================================================


+ 3
- 3
modules/juce_gui_basics/mouse/juce_SelectedItemSet.h View File

@@ -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());
}
}


+ 1
- 1
modules/juce_gui_basics/widgets/juce_Toolbar.cpp View File

@@ -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…
Cancel
Save