OpenShot Audio Library | OpenShotAudio 0.4.0
|
#include <juce_SortedSet.h>
Public Types | |
using | ScopedLockType = typename TypeOfCriticalSectionToUse::ScopedLockType |
Holds a set of unique primitive objects, such as ints or doubles.
A set can only hold one item with a given value, so if for example it's a set of integers, attempting to add the same integer twice will do nothing the second time.
Internally, the list of items is kept sorted (which means that whatever kind of primitive type is used must support the ==, <, >, <= and >= operators to determine the order), and searching the set for known values is very fast because it uses a binary-chop method.
Note that if you're using a class or struct as the element type, it must be capable of being copied or moved with a straightforward memcpy, rather than needing construction and destruction code.
To make all the set's methods thread-safe, pass in "CriticalSection" as the templated TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection.
Definition at line 53 of file juce_SortedSet.h.
using juce::SortedSet< ElementType, TypeOfCriticalSectionToUse >::ScopedLockType = typename TypeOfCriticalSectionToUse::ScopedLockType |
Returns the type of scoped lock to use for locking this array
Definition at line 479 of file juce_SortedSet.h.
|
default |
Creates an empty set.
|
default |
Creates a copy of another set.
|
defaultnoexcept |
Creates a copy of another set.
|
default |
Destructor.
|
inlinenoexcept |
Adds a new element to the set, (as long as it's not already in there).
Note that if a matching element already exists, the new value will be assigned to the existing one using operator=, so that if there are any differences between the objects which were not recognised by the object's operator==, then the set will always contain a copy of the most recently added one.
newElement | the new object to add to the set |
Definition at line 271 of file juce_SortedSet.h.
|
inlinenoexcept |
Adds elements from an array to this set.
elementsToAdd | the array of elements to add |
numElementsToAdd | how many elements are in this other array |
Definition at line 315 of file juce_SortedSet.h.
|
inlinenoexcept |
Adds elements from another set to this one.
setToAddFrom | the set from which to copy the elements |
startIndex | the first element of the other set to start copying from |
numElementsToAdd | how many elements to add from the other set. If this value is negative or greater than the number of available elements, all available elements will be copied. |
Definition at line 334 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns a pointer to the first element in the set. This method is provided for compatibility with standard C++ iteration mechanisms.
Definition at line 200 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes all elements from the set.
This will remove all the elements, and free any storage that the set is using. To clear it without freeing the storage, use the clearQuick() method instead.
Definition at line 103 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes all elements from the set without freeing the array's allocated storage.
Definition at line 111 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns true if the set contains at least one occurrence of an object.
elementToLookFor | the value or object to look for |
Definition at line 254 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns a pointer to the element which follows the last element in the set. This method is provided for compatibility with standard C++ iteration mechanisms.
Definition at line 208 of file juce_SortedSet.h.
|
inline |
Increases the set's internal storage to hold a minimum number of elements.
Calling this before adding a large known number of elements means that the set won't have to keep dynamically resizing itself as the elements are added, and it'll therefore be more efficient.
Definition at line 466 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns the first element in the set, or 0 if the set is empty.
Definition at line 183 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns the last element in the set, or 0 if the set is empty.
Definition at line 191 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns the CriticalSection that locks this array. To lock, you can call getLock().enter() and getLock().exit(), or preferably use an object of ScopedLockType as an RAII lock for it.
Definition at line 476 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns a direct reference to one of the elements in the set, without checking the index passed in.
index | the index of the element being requested (0 is the first element in the array) |
Definition at line 175 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns a direct reference to one of the elements in the set, without checking the index passed in.
This is like getUnchecked, but returns a direct reference to the element, so that you can alter it directly. Obviously this can be dangerous, so only use it when absolutely necessary.
index | the index of the element being requested (0 is the first element in the array) |
Definition at line 166 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns one of the elements in the set, without checking the index passed in. Unlike the operator[] method, this will try to return an element without checking that the index is within the bounds of the set, so should only be used when you're confident that it will always be a valid index.
index | the index of the element being requested (0 is the first element in the set) |
Definition at line 153 of file juce_SortedSet.h.
|
inlinenoexcept |
Finds the index of the first element which matches the value passed in.
This will search the set for the given object, and return the index of its first occurrence. If the object isn't found, the method will return -1.
elementToLookFor | the value or object to look for |
Definition at line 222 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns true if the set is empty, false otherwise.
Definition at line 124 of file juce_SortedSet.h.
|
inlinenoexcept |
Reduces the amount of storage being used by the set.
Sets typically allocate slightly more storage than they need, and after removing elements, they may have quite a lot of unused space allocated. This method will reduce the amount of allocated storage to a minimum.
Definition at line 455 of file juce_SortedSet.h.
|
inlinenoexcept |
Compares this set to another one. Two sets are considered equal if they both contain the same set of elements.
other | the other set to compare with |
Definition at line 89 of file juce_SortedSet.h.
|
default |
Makes a copy of another set.
|
defaultnoexcept |
Makes a copy of another set.
|
inlinenoexcept |
Compares this set to another one. Two sets are considered equal if they both contain the same set of elements.
other | the other set to compare with |
Definition at line 80 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns one of the elements in the set.
If the index passed in is beyond the range of valid elements, this will return zero.
If you're certain that the index will always be a valid element, you can call getUnchecked() instead, which is faster.
index | the index of the element being requested (0 is the first element in the set) |
Definition at line 140 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes an element from the set.
This will remove the element at a given index. If the index passed in is out-of-range, nothing will happen.
indexToRemove | the index of the element to remove |
Definition at line 368 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes an item from the set.
This will remove the given element from the set, if it's there.
valueToRemove | the object to try to remove |
Definition at line 380 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes any elements which are also in another set.
otherSet | the other set in which to look for elements to remove |
Definition at line 392 of file juce_SortedSet.h.
|
inlinenoexcept |
Removes any elements which are not found in another set.
Only elements which occur in this other set will be retained.
otherSet | the set in which to look for elements NOT to remove |
Definition at line 417 of file juce_SortedSet.h.
|
inlinenoexcept |
Returns the current number of elements in the set.
Definition at line 118 of file juce_SortedSet.h.
|
inlinenoexcept |
This swaps the contents of this array with those of another array.
If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers.
Definition at line 443 of file juce_SortedSet.h.