|
|
|
@@ -58,7 +58,7 @@ private: |
|
|
|
public:
|
|
|
|
//==============================================================================
|
|
|
|
/** Creates an empty array. */
|
|
|
|
Array() noexcept : numUsed (0)
|
|
|
|
Array() noexcept
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -82,19 +82,17 @@ public: |
|
|
|
other.numUsed = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initalises from a null-terminated C array of values.
|
|
|
|
|
|
|
|
/** Initalises from a null-terminated raw array of values.
|
|
|
|
@param values the array to copy from
|
|
|
|
*/
|
|
|
|
template <typename TypeToCreateFrom>
|
|
|
|
explicit Array (const TypeToCreateFrom* values) : numUsed (0)
|
|
|
|
explicit Array (const TypeToCreateFrom* values)
|
|
|
|
{
|
|
|
|
while (*values != TypeToCreateFrom())
|
|
|
|
add (*values++);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initalises from a C array of values.
|
|
|
|
|
|
|
|
/** Initalises from a raw array of values.
|
|
|
|
@param values the array to copy from
|
|
|
|
@param numValues the number of values in the array
|
|
|
|
*/
|
|
|
|
@@ -107,13 +105,33 @@ public: |
|
|
|
new (data.elements + i) ElementType (values[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if JUCE_COMPILER_SUPPORTS_INITIALIZER_LISTS
|
|
|
|
template <typename TypeToCreateFrom>
|
|
|
|
Array (const std::initializer_list<TypeToCreateFrom>& items) : numUsed (0)
|
|
|
|
/** Initalises an Array of size 1 containing a single element. */
|
|
|
|
explicit Array (const ElementType& singleElementToAdd)
|
|
|
|
{
|
|
|
|
addArray (items);
|
|
|
|
add (singleElementToAdd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initalises an Array of size 1 containing a single element. */
|
|
|
|
explicit Array (ElementType&& singleElementToAdd)
|
|
|
|
{
|
|
|
|
add (static_cast<ElementType&&> (singleElementToAdd));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initalises an Array from a list of items. */
|
|
|
|
template <typename... OtherElements>
|
|
|
|
Array (const ElementType& firstNewElement, OtherElements... otherElements)
|
|
|
|
{
|
|
|
|
data.ensureAllocatedSize (1 + (int) sizeof... (otherElements));
|
|
|
|
addAssumingCapacityIsReady (firstNewElement, otherElements...);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Initalises an Array from a list of items. */
|
|
|
|
template <typename... OtherElements>
|
|
|
|
Array (ElementType&& firstNewElement, OtherElements... otherElements)
|
|
|
|
{
|
|
|
|
data.ensureAllocatedSize (1 + (int) sizeof... (otherElements));
|
|
|
|
addAssumingCapacityIsReady (static_cast<ElementType&&> (firstNewElement), otherElements...);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Destructor. */
|
|
|
|
~Array()
|
|
|
|
@@ -128,7 +146,7 @@ public: |
|
|
|
{
|
|
|
|
if (this != &other)
|
|
|
|
{
|
|
|
|
Array<ElementType, TypeOfCriticalSectionToUse> otherCopy (other);
|
|
|
|
auto otherCopy (other);
|
|
|
|
swapWith (otherCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1221,7 +1239,7 @@ public: |
|
|
|
private:
|
|
|
|
//==============================================================================
|
|
|
|
ArrayAllocationBase <ElementType, TypeOfCriticalSectionToUse> data;
|
|
|
|
int numUsed;
|
|
|
|
int numUsed = 0;
|
|
|
|
|
|
|
|
void removeInternal (const int indexToRemove)
|
|
|
|
{
|
|
|
|
|