Blend2D
2D Vector Graphics Engine
Array container (template) [C++ API].
Move constructor.
other
array is always reset by a move construction, so it becomes an empty array. Copy constructor, performs weak copy of the data held by the other
array.
Tests whether the array has items. Returns true
if the array is not empty.
empty()
. Move assignment.
other
array is reset by move assignment, so its state after the move operation is the same as the default constructed array. Copy assignment, performs weak copy of the data held by the other
array.
Returns true if this and other
arrays are equal.
Returns true if this and other
arrays are not equal.
Returns a read-only reference to the array item at the given index
.
at(index)
. Resets the array into a default constructed state by clearing its content and releasing its memory.
Swaps the content of this array with the other
array.
Returns the size of the array (number of items).
Returns the capacity of the array (number of items).
Returns a pointer to the array data.
Returns a pointer to the array data (iterator compatibility).
Returns a pointer to the end of array data (iterator compatibility).
Returns the array data as BLArrayView<T>
.
Returns a read-only reference to the array item at the given index
.
Returns a read-only reference to the first item.
first()
would point to the end of the array, which is not initialized, and such reference would be invalid. Debug builds would catch this condition with an assertion. Returns a read-only reference to the last item.
last()
would point to the end of the array, which is not initialized, and such reference would be invalid. Debug builds would catch this condition with an assertion. Clears the content of the array.
reset()
if you want to release the memory in such case instead. Shrinks the capacity of the array to fit its length.
Some array operations like append()
may grow the array more than necessary to make it faster when such manipulation operations are called consecutively. When you are done with modifications and you know the lifetime of the array won't be short you can use shrink()
to fit its memory requirements to the number of items it stores, which could optimize the application's memory requirements.
Reserves the array capacity to hold at least n
items.
Truncates the length of the array to maximum n
items.
If the length of the array is less than n
n then truncation does nothing.
Resizes the array to n
items.
If n
is greater than the array length then all new items will be initialized by fill
item.
Makes the array mutable by possibly creating a deep copy of the data if it's either read-only or shared with another array. Stores the pointer to the beginning of mutable data in dataOut
.
Modify operation is similar to makeMutable
, however, the op
argument specifies the desired array operation, see BLModifyOp. The pointer returned in dataOut
points to the first item to be either assigned or appended and it points to an uninitialized memory.
Please note that assignments mean to wipe out the whole array content and to set the length of the array to n
. The caller is responsible for initializing the data returned in dataOut
.
Insert operation, the semantics is similar to modifyOp()
, however, items are inserted at the given index
instead of assigned or appended.
The caller is responsible for initializing the data returned in dataOut
.
Similar to modifyOp()
, but the items to assign/append to the array are given after the op
argument.
Move assignment, the same as operator=
, but returns a BLResult
instead of this
.
Copy assignment, the same as operator=
, but returns a BLResult
instead of this
.
Copy assignment, but creates a deep copy of the other
array instead of weak copy.
Replaces the content of the array with variadic number of items passed in args...
.
Replaces the content of the array by items in the passed array view
.
view
pointing to the array's data as well, so it's possible to create a slice of the array if required. Replaces the content of the array items
of length n
.
Assign an external buffer to the array, which would replace the existing content.
data | External data buffer to use (cannot be NULL). |
size | Size of the data buffer in items. |
capacity | Capacity of the buffer, cannot be zero or smaller than size . |
accessFlags | Flags that describe whether the data is read-only or read-write, see BLDataAccessFlags. |
destroyFunc | A function that would be called when the array is destroyed (can be null if you don't need it). |
userData | User data passed to destroyFunc . |
Appends a variadic number of items items passed in args...
to the array.
args
cannot point to the same data that the array holds as the function that prepares the append operation has no way to know about the source (it only makes space for new data). It's an undefined behavior in such case. Appends items to the array of the given array view
.
view
pointing to the array data itself would work. Appends items
to the array of length n
.
items
pointing to the array data itself would work. Prepends a variadic number of items items passed in args...
to the array.
args
cannot point to the same data that the array holds as the function that prepares the prepend operation has no way to know about the source (it only makes space for new data). It's an undefined behavior in such case. Prepends items to the array of the given array view
.
view
pointing to the array data itself would work. Prepends items
to the array of length n
.
items
pointing to the array data itself would work. Inserts a variadic number of items items passed in args...
at the given index
.
args
cannot point to the same data that the array holds as the function that prepares the insert operation has no way to know about the source (it only makes space for new data). It's an undefined behavior in such case. Inserts items to the array of the given array view
at the given index
.
view
pointing to the array data itself would work. Prepends items
to the array of length n
at the given index
.
items
pointing to the array data itself would work. Replaces an item at the given index
by item
.
Replaces the given range
of items by the given array view
.
Replaces the given range
of items by items
of length n
.
Removes an item at the given index
.
Removes a range
of items.
Returns whether the content of this array and other
matches.
Returns the first index at which a given item
can be found in the array, or SIZE_MAX
if not found.
Returns the index at which a given item
can be found in the array starting from fromIndex
, or SIZE_MAX
if not present.