Browse Source

Added a new method Array::sort() which uses the default comparator for simple types

tags/2021-05-28
jules 10 years ago
parent
commit
4fd8913037
2 changed files with 12 additions and 4 deletions
  1. +1
    -3
      modules/juce_audio_devices/native/juce_win32_ASIO.cpp
  2. +11
    -1
      modules/juce_core/containers/juce_Array.h

+ 1
- 3
modules/juce_audio_devices/native/juce_win32_ASIO.cpp View File

@@ -941,9 +941,7 @@ private:
}
bufferSizes.addIfNotAlreadyThere (preferredSize);
DefaultElementComparator <int> comparator;
bufferSizes.sort (comparator);
bufferSizes.sort();
}
double getSampleRate() const


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

@@ -1053,6 +1053,16 @@ public:
}
//==============================================================================
/** Sorts the array using a default comparison operation.
If the type of your elements isn't supported by the DefaultElementComparator class
then you may need to use the other version of sort, which takes a custom comparator.
*/
void sort()
{
DefaultElementComparator<ElementType> comparator;
sort (comparator);
}
/** Sorts the elements in the array.
This will use a comparator object to sort the elements into order. The object
@@ -1081,7 +1091,7 @@ public:
*/
template <class ElementComparator>
void sort (ElementComparator& comparator,
const bool retainOrderOfEquivalentItems = false) const
const bool retainOrderOfEquivalentItems = false)
{
const ScopedLockType lock (getLock());
(void) comparator; // if you pass in an object with a static compareElements() method, this


Loading…
Cancel
Save