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

Renamed the swapWithArray methods in the array classes to "swapWith" to be more consistent with other swap method naming, and templated the methods for more flexibility.

This commit is contained in:
jules 2013-07-28 11:31:25 +01:00
parent 19b7d59c14
commit 5b25ac6609
17 changed files with 47 additions and 31 deletions

View file

@ -111,7 +111,7 @@ void AppearanceSettings::refreshPresetSchemeList()
if (newSchemes != presetSchemeFiles)
{
presetSchemeFiles.swapWithArray (newSchemes);
presetSchemeFiles.swapWith (newSchemes);
commandManager->commandStatusChanged();
}
}

View file

@ -43,7 +43,7 @@ MidiMessageSequence& MidiMessageSequence::operator= (const MidiMessageSequence&
void MidiMessageSequence::swapWith (MidiMessageSequence& other) noexcept
{
list.swapWithArray (other.list);
list.swapWith (other.list);
}
MidiMessageSequence::~MidiMessageSequence()

View file

@ -387,7 +387,7 @@ public:
if (sampleRates != newRates)
{
sampleRates.swapWithArray (newRates);
sampleRates.swapWith (newRates);
#if JUCE_ASIO_DEBUGGING
StringArray s;

View file

@ -162,7 +162,7 @@ bool BufferingAudioReader::readNextBufferChunk()
{
const ScopedLock sl (lock);
newBlocks.swapWithArray (blocks);
newBlocks.swapWith (blocks);
}
for (int i = blocks.size(); --i >= 0;)

View file

@ -1180,7 +1180,7 @@ void AudioProcessorGraph::clearRenderingSequence()
{
const ScopedLock sl (getCallbackLock());
renderingOps.swapWithArray (oldOps);
renderingOps.swapWith (oldOps);
}
deleteRenderOpArray (oldOps);
@ -1254,7 +1254,7 @@ void AudioProcessorGraph::buildRenderingSequence()
while (midiBuffers.size() < numMidiBuffersNeeded)
midiBuffers.add (new MidiBuffer());
renderingOps.swapWithArray (newRenderingOps);
renderingOps.swapWith (newRenderingOps);
}
// delete the old ones..

View file

@ -137,7 +137,7 @@ public:
if (this != &other)
{
Array<ElementType, TypeOfCriticalSectionToUse> otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
}
return *this;
@ -576,11 +576,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (Array& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@ -1025,6 +1025,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (Array& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ElementType, TypeOfCriticalSectionToUse> data;

View file

@ -317,12 +317,13 @@ public:
//==============================================================================
/** Efficiently swaps the contents of two hash-maps. */
void swapWith (HashMap& otherHashMap) noexcept
template <class OtherHashMapType>
void swapWith (OtherHashMapType& otherHashMap) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherHashMap.getLock());
const typename OtherHashMapType::ScopedLockType lock2 (otherHashMap.getLock());
slots.swapWithArray (otherHashMap.slots);
slots.swapWith (otherHashMap.slots);
std::swap (totalNumItems, otherHashMap.totalNumItems);
}

View file

@ -792,11 +792,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (OwnedArray& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@ -874,6 +874,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (OwnedArray& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;

View file

@ -96,7 +96,7 @@ public:
ReferenceCountedArray& operator= (const ReferenceCountedArray& other) noexcept
{
ReferenceCountedArray otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
return *this;
}
@ -107,7 +107,7 @@ public:
ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& operator= (const ReferenceCountedArray<OtherObjectClass, TypeOfCriticalSectionToUse>& other) noexcept
{
ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse> otherCopy (other);
swapWithArray (otherCopy);
swapWith (otherCopy);
return *this;
}
@ -745,11 +745,11 @@ public:
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
because it just swaps their internal pointers.
*/
void swapWithArray (ReferenceCountedArray& otherArray) noexcept
template <class OtherArrayType>
void swapWith (OtherArrayType& otherArray) noexcept
{
const ScopedLockType lock1 (getLock());
const ScopedLockType lock2 (otherArray.getLock());
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
data.swapWith (otherArray.data);
std::swap (numUsed, otherArray.numUsed);
}
@ -857,6 +857,11 @@ public:
typedef typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType;
//==============================================================================
// Note that the swapWithArray method has been replaced by a more flexible templated version,
// and renamed "swapWith" to be more consistent with the names used in other classes.
JUCE_DEPRECATED_WITH_BODY (void swapWithArray (ReferenceCountedArray& other) noexcept, { swapWith (other); })
private:
//==============================================================================
ArrayAllocationBase <ObjectClass*, TypeOfCriticalSectionToUse> data;

View file

@ -450,7 +450,7 @@ public:
*/
void swapWith (SortedSet& otherSet) noexcept
{
data.swapWithArray (otherSet.data);
data.swapWith (otherSet.data);
}
//==============================================================================

View file

@ -127,7 +127,7 @@ bool StringArray::operator!= (const StringArray& other) const noexcept
void StringArray::swapWith (StringArray& other) noexcept
{
strings.swapWithArray (other.strings);
strings.swapWith (other.strings);
}
void StringArray::clear()

View file

@ -332,7 +332,7 @@ bool RectangleList::getIntersectionWith (const Rectangle<int>& rect, RectangleLi
void RectangleList::swapWith (RectangleList& otherList) noexcept
{
rects.swapWithArray (otherList.rects);
rects.swapWith (otherList.rects);
}

View file

@ -420,7 +420,7 @@ void Desktop::Displays::init (Desktop& desktop)
void Desktop::Displays::refresh()
{
Array<Display> oldDisplays;
oldDisplays.swapWithArray (displays);
oldDisplays.swapWith (displays);
init (Desktop::getInstance());

View file

@ -1150,14 +1150,14 @@ PopupMenu& PopupMenu::operator= (const PopupMenu& other)
PopupMenu::PopupMenu (PopupMenu&& other) noexcept
: lookAndFeel (other.lookAndFeel)
{
items.swapWithArray (other.items);
items.swapWith (other.items);
}
PopupMenu& PopupMenu::operator= (PopupMenu&& other) noexcept
{
jassert (this != &other); // hopefully the compiler should make this situation impossible!
items.swapWithArray (other.items);
items.swapWith (other.items);
lookAndFeel = other.lookAndFeel;
return *this;
}

View file

@ -94,7 +94,7 @@ bool RelativePointPath::operator!= (const RelativePointPath& other) const noexce
void RelativePointPath::swapWith (RelativePointPath& other) noexcept
{
elements.swapWithArray (other.elements);
elements.swapWith (other.elements);
std::swap (usesNonZeroWinding, other.usesNonZeroWinding);
std::swap (containsDynamicPoints, other.containsDynamicPoints);
}

View file

@ -22,7 +22,7 @@
==============================================================================
*/
static uint32 lastUniqueID = 1;
static uint32 lastUniquePeerID = 1;
//==============================================================================
ComponentPeer::ComponentPeer (Component& comp, const int flags)
@ -30,7 +30,7 @@ ComponentPeer::ComponentPeer (Component& comp, const int flags)
styleFlags (flags),
constrainer (nullptr),
lastDragAndDropCompUnderMouse (nullptr),
uniqueID (lastUniqueID += 2), // increment by 2 so that this can never hit 0
uniqueID (lastUniquePeerID += 2), // increment by 2 so that this can never hit 0
isWindowMinimised (false)
{
Desktop::getInstance().peers.add (this);

View file

@ -76,7 +76,7 @@ public:
return false;
}
tokens.swapWithArray (newTokens);
tokens.swapWith (newTokens);
return true;
}