mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Rename to swapWith and use a template parameter
This commit is contained in:
@@ -132,7 +132,7 @@ public:
|
|||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
Array<ElementType, TypeOfCriticalSectionToUse> otherCopy (other);
|
Array<ElementType, TypeOfCriticalSectionToUse> otherCopy (other);
|
||||||
swapWithArray (otherCopy);
|
swapWith (otherCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@@ -577,7 +577,7 @@ public:
|
|||||||
because it just swaps their internal pointers.
|
because it just swaps their internal pointers.
|
||||||
*/
|
*/
|
||||||
template <class OtherArrayType>
|
template <class OtherArrayType>
|
||||||
void swapWithArray (OtherArrayType& otherArray) noexcept
|
void swapWith (OtherArrayType& otherArray) noexcept
|
||||||
{
|
{
|
||||||
const ScopedLockType lock1 (getLock());
|
const ScopedLockType lock1 (getLock());
|
||||||
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
|
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
|
||||||
|
|||||||
@@ -354,12 +354,13 @@ public:
|
|||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Efficiently swaps the contents of two hash-maps. */
|
/** 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 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);
|
std::swap (totalNumItems, otherHashMap.totalNumItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -788,10 +788,11 @@ public:
|
|||||||
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
|
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
|
||||||
because it just swaps their internal pointers.
|
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 lock1 (getLock());
|
||||||
const ScopedLockType lock2 (otherArray.getLock());
|
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
|
||||||
|
|
||||||
data.swapWith (otherArray.data);
|
data.swapWith (otherArray.data);
|
||||||
std::swap (numUsed, otherArray.numUsed);
|
std::swap (numUsed, otherArray.numUsed);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
SharedObjectArray& operator= (const SharedObjectArray& other) noexcept
|
SharedObjectArray& operator= (const SharedObjectArray& other) noexcept
|
||||||
{
|
{
|
||||||
SharedObjectArray otherCopy (other);
|
SharedObjectArray otherCopy (other);
|
||||||
swapWithArray (otherCopy);
|
swapWith (otherCopy);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
SharedObjectArray<ObjectClass, TypeOfCriticalSectionToUse>& operator= (const SharedObjectArray<OtherObjectClass, TypeOfCriticalSectionToUse>& other) noexcept
|
SharedObjectArray<ObjectClass, TypeOfCriticalSectionToUse>& operator= (const SharedObjectArray<OtherObjectClass, TypeOfCriticalSectionToUse>& other) noexcept
|
||||||
{
|
{
|
||||||
SharedObjectArray<ObjectClass, TypeOfCriticalSectionToUse> otherCopy (other);
|
SharedObjectArray<ObjectClass, TypeOfCriticalSectionToUse> otherCopy (other);
|
||||||
swapWithArray (otherCopy);
|
swapWith (otherCopy);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,7 +741,7 @@ public:
|
|||||||
because it just swaps their internal pointers.
|
because it just swaps their internal pointers.
|
||||||
*/
|
*/
|
||||||
template <class OtherArrayType>
|
template <class OtherArrayType>
|
||||||
void swapWithArray (OtherArrayType& otherArray) noexcept
|
void swapWith (OtherArrayType& otherArray) noexcept
|
||||||
{
|
{
|
||||||
const ScopedLockType lock1 (getLock());
|
const ScopedLockType lock1 (getLock());
|
||||||
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
|
const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock());
|
||||||
|
|||||||
@@ -443,9 +443,10 @@ public:
|
|||||||
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
|
If you need to exchange two arrays, this is vastly quicker than using copy-by-value
|
||||||
because it just swaps their internal pointers.
|
because it just swaps their internal pointers.
|
||||||
*/
|
*/
|
||||||
void swapWith (SortedSet& otherSet) noexcept
|
template <class OtherSortedSetType>
|
||||||
|
void swapWith (OtherSortedSetType& otherSet) noexcept
|
||||||
{
|
{
|
||||||
data.swapWithArray (otherSet.data);
|
data.swapWith (otherSet.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ bool StringArray::operator!= (const StringArray& other) const noexcept
|
|||||||
|
|
||||||
void StringArray::swapWith (StringArray& other) noexcept
|
void StringArray::swapWith (StringArray& other) noexcept
|
||||||
{
|
{
|
||||||
strings.swapWithArray (other.strings);
|
strings.swapWith (other.strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringArray::clear()
|
void StringArray::clear()
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
|
|
||||||
explicit List (SharedObjectArray <Validator>& list)
|
explicit List (SharedObjectArray <Validator>& list)
|
||||||
{
|
{
|
||||||
m_list.swapWithArray (list);
|
m_list.swapWith (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
~List ()
|
~List ()
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public:
|
|||||||
sorted.addSorted (compare, arrayToSort [i]);
|
sorted.addSorted (compare, arrayToSort [i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayToSort.swapWithArray (sorted);
|
arrayToSort.swapWith (sorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given the old list and the new list for a source, this
|
// Given the old list and the new list for a source, this
|
||||||
|
|||||||
Reference in New Issue
Block a user