Go to the documentation of this file.
29 #ifndef JUCE_SORTEDSET_H_INCLUDED
30 #define JUCE_SORTEDSET_H_INCLUDED
33 #pragma warning (push)
34 #pragma warning (disable: 4512)
59 template <
class ElementType,
class TypeOfCriticalSectionToUse = DummyCriticalSection>
98 return data == other.data;
165 return data.getUnchecked (index);
178 return data.getReference (index);
186 return data.getFirst();
194 return data.getLast();
235 if (elementToLookFor == data.getReference (s))
238 const int halfway = (s + e) / 2;
243 if (elementToLookFor < data.getReference (halfway))
257 return indexOf (elementToLookFor) >= 0;
281 ElementType& elem = data.getReference (s);
282 if (newElement == elem)
288 const int halfway = (s + e) / 2;
289 const bool isBeforeHalfway = (newElement < data.getReference (halfway));
293 if (! isBeforeHalfway)
305 data.insert (s, newElement);
320 while (--numElementsToAdd >= 0)
321 add (*elementsToAdd++);
333 template <
class OtherSetType>
334 void addSet (
const OtherSetType& setToAddFrom,
338 const typename OtherSetType::ScopedLockType lock1 (setToAddFrom.getLock());
342 jassert (
this != &setToAddFrom);
344 if (
this != &setToAddFrom)
352 if (numElementsToAdd < 0 || startIndex + numElementsToAdd > setToAddFrom.size())
353 numElementsToAdd = setToAddFrom.size() - startIndex;
355 if (numElementsToAdd > 0)
356 addArray (&setToAddFrom.data.getReference (startIndex), numElementsToAdd);
373 return data.remove (indexToRemove);
386 data.remove (
indexOf (valueToRemove));
394 template <
class OtherSetType>
397 const typename OtherSetType::ScopedLockType lock1 (otherSet.getLock());
400 if (
this == &otherSet)
404 else if (otherSet.size() > 0)
406 for (
int i = data.size(); --i >= 0;)
407 if (otherSet.contains (data.getReference (i)))
419 template <
class OtherSetType>
422 const typename OtherSetType::ScopedLockType lock1 (otherSet.getLock());
425 if (
this != &otherSet)
427 if (otherSet.size() <= 0)
433 for (
int i = data.size(); --i >= 0;)
434 if (! otherSet.contains (data.getReference (i)))
445 template <
class OtherSetType>
448 data.swapWith (otherSet.data);
460 data.minimiseStorageOverheads();
471 data.ensureStorageAllocated (minNumElements);
479 inline const TypeOfCriticalSectionToUse&
getLock() const
noexcept {
return data.getLock(); }
491 #pragma warning (pop)
494 #endif // JUCE_SORTEDSET_H_INCLUDED
ElementType remove(const int indexToRemove) noexcept
Definition: juce_SortedSet.h:371
void swapWith(OtherSetType &otherSet) noexcept
Definition: juce_SortedSet.h:446
ElementType getUnchecked(const int index) const noexcept
Definition: juce_SortedSet.h:163
SortedSet & operator=(const SortedSet &other) noexcept
Definition: juce_SortedSet.h:85
~SortedSet() noexcept
Definition: juce_SortedSet.h:78
Definition: juce_SortedSet.h:60
ElementType getFirst() const noexcept
Definition: juce_SortedSet.h:184
void removeValuesIn(const OtherSetType &otherSet) noexcept
Definition: juce_SortedSet.h:395
DummyCriticalSection ::ScopedLockType ScopedLockType
Definition: juce_SortedSet.h:482
int size() const noexcept
Definition: juce_SortedSet.h:134
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Array.h:60
ElementType getLast() const noexcept
Definition: juce_SortedSet.h:192
void removeValuesNotIn(const OtherSetType &otherSet) noexcept
Definition: juce_SortedSet.h:420
ElementType & getReference(const int index) const noexcept
Definition: juce_SortedSet.h:176
void clearQuick() noexcept
Definition: juce_SortedSet.h:127
bool add(const ElementType &newElement) noexcept
Definition: juce_SortedSet.h:272
bool operator==(const SortedSet< ElementType > &other) const noexcept
Definition: juce_SortedSet.h:96
SortedSet() noexcept
Definition: juce_SortedSet.h:65
void removeValue(const ElementType valueToRemove) noexcept
Definition: juce_SortedSet.h:383
void addSet(const OtherSetType &setToAddFrom, int startIndex=0, int numElementsToAdd=-1) noexcept
Definition: juce_SortedSet.h:334
void ensureStorageAllocated(const int minNumElements)
Definition: juce_SortedSet.h:469
void minimiseStorageOverheads() noexcept
Definition: juce_SortedSet.h:458
void clear() noexcept
Definition: juce_SortedSet.h:119
int indexOf(const ElementType &elementToLookFor) const noexcept
Definition: juce_SortedSet.h:223
const TypeOfCriticalSectionToUse & getLock() const noexcept
Definition: juce_SortedSet.h:479
ElementType * begin() const noexcept
Definition: juce_SortedSet.h:201
ElementType * end() const noexcept
Definition: juce_SortedSet.h:209
void addArray(const ElementType *elementsToAdd, int numElementsToAdd) noexcept
Definition: juce_SortedSet.h:315
bool contains(const ElementType &elementToLookFor) const noexcept
Definition: juce_SortedSet.h:255
SortedSet(const SortedSet &other)
Definition: juce_SortedSet.h:72
ElementType operator[](const int index) const noexcept
Definition: juce_SortedSet.h:150
bool operator!=(const SortedSet< ElementType > &other) const noexcept
Definition: juce_SortedSet.h:105