26JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4512)
80 bool operator== (const
SortedSet<ElementType>& other) const noexcept
82 return data == other.data;
91 return ! operator== (other);
118 inline int size() const noexcept
140 inline ElementType operator[] (
const int index)
const noexcept
155 return data.getUnchecked (index);
168 return data.getReference (index);
175 inline const ElementType&
getReference (
const int index)
const noexcept
177 return data.getReference (index);
185 return data.getFirst();
193 return data.getLast();
200 inline const ElementType*
begin() const noexcept
208 inline const ElementType*
end() const noexcept
222 int indexOf (
const ElementType& elementToLookFor)
const noexcept
234 if (elementToLookFor == data.getReference (s))
237 auto halfway = (s + e) / 2;
242 if (elementToLookFor < data.getReference (halfway))
254 bool contains (
const ElementType& elementToLookFor)
const noexcept
256 return indexOf (elementToLookFor) >= 0;
271 bool add (
const ElementType& newElement)
noexcept
280 auto& elem = data.getReference (s);
282 if (newElement == elem)
288 auto halfway = (s + e) / 2;
289 bool isBeforeHalfway = (newElement < data.getReference (halfway));
293 if (! isBeforeHalfway)
305 data.insert (s, newElement);
316 int numElementsToAdd)
noexcept
320 while (--numElementsToAdd >= 0)
321 add (*elementsToAdd++);
333 template <
class OtherSetType>
334 void addSet (
const OtherSetType& setToAddFrom,
336 int numElementsToAdd = -1) noexcept
338 const typename OtherSetType::ScopedLockType lock1 (setToAddFrom.getLock());
340 jassert (
this != &setToAddFrom);
342 if (
this != &setToAddFrom)
350 if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size())
351 numElementsToAdd = setToAddFrom.size() - startIndex;
353 if (numElementsToAdd > 0)
354 addArray (&setToAddFrom.data.getReference (startIndex), numElementsToAdd);
368 ElementType
remove (
const int indexToRemove)
noexcept
370 return data.removeAndReturn (indexToRemove);
383 data.remove (
indexOf (valueToRemove));
391 template <
class OtherSetType>
394 const typename OtherSetType::ScopedLockType lock1 (otherSet.getLock());
397 if (
this == &otherSet)
401 else if (! otherSet.isEmpty())
403 for (
int i = data.size(); --i >= 0;)
404 if (otherSet.contains (data.getReference (i)))
416 template <
class OtherSetType>
419 const typename OtherSetType::ScopedLockType lock1 (otherSet.getLock());
422 if (
this != &otherSet)
424 if (otherSet.isEmpty())
430 for (
int i = data.size(); --i >= 0;)
431 if (! otherSet.contains (data.getReference (i)))
442 template <
class OtherSetType>
445 data.swapWith (otherSet.data);
457 data.minimiseStorageOverheads();
468 data.ensureStorageAllocated (minNumElements);
476 inline const TypeOfCriticalSectionToUse&
getLock() const noexcept {
return data.getLock(); }
487JUCE_END_IGNORE_WARNINGS_MSVC
int size() const noexcept
ElementType remove(const int indexToRemove) noexcept
bool isEmpty() const noexcept
int indexOf(const ElementType &elementToLookFor) const noexcept
void addSet(const OtherSetType &setToAddFrom, int startIndex=0, int numElementsToAdd=-1) noexcept
void addArray(const ElementType *elementsToAdd, int numElementsToAdd) noexcept
const ElementType & getReference(const int index) const noexcept
ElementType getFirst() const noexcept
void removeValuesIn(const OtherSetType &otherSet) noexcept
bool add(const ElementType &newElement) noexcept
void clearQuick() noexcept
ElementType getUnchecked(const int index) const noexcept
const TypeOfCriticalSectionToUse & getLock() const noexcept
SortedSet(SortedSet &&) noexcept=default
SortedSet(const SortedSet &)=default
void swapWith(OtherSetType &otherSet) noexcept
void minimiseStorageOverheads() noexcept
ElementType getLast() const noexcept
void ensureStorageAllocated(const int minNumElements)
ElementType & getReference(const int index) noexcept
const ElementType * end() const noexcept
void removeValue(const ElementType &valueToRemove) noexcept
bool contains(const ElementType &elementToLookFor) const noexcept
const ElementType * begin() const noexcept
void removeValuesNotIn(const OtherSetType &otherSet) noexcept
typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType