file
VectorDef.hThis module provides macro definitions for implementing and working with CnxVector(T)
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defines
- #define CnxVector(T)
- macro alias for a
CnxVector(T)
containingT
s - #define CnxVectorIterator(T)
- macro alias for the concrete type for an iterator into the mutable iteration of a
CnxVector(T)
containingT
s - #define CnxVectorConstIterator(T)
- macro alias for the concrete type for an iterator into the const iteration of a
CnxVector(T)
containingT
s - #define CnxVectorIdentifier(T, Identifier)
- macro alias for an identifier (type, function, etc) associated with a
CnxVector(T)
containingT
s - #define CNX_VECTOR_DEFAULT_SHORT_OPT_CAPACITY
- The default small-vector optimization capacity if not given as a template parameter.
- #define CNX_VECTOR_DEFAULT_LONG_CAPACITY
- The default heap-allocated capacity if not given as a template parameter.
- #define cnx_vector_new(T)
- Creates a new
CnxVector(T)
with defaulted associated functions and initial capacity. - #define cnx_vector_new_with_allocator(T, allocator)
- Creates a new
CnxVector(T)
with defaulted capacity and associated functions and provided memory allocator. - #define cnx_vector_new_with_collection_data(T, collection_data_ptr)
- Creates a new
CnxVector(T)
with defaulted capacity and provided associated functions. - #define cnx_vector_new_with_allocator_and_collection_data(T, allocator, collection_data_ptr)
- Creates a new
CnxVector(T)
with defaulted capacity and provided associated functions and memory allocator. - #define cnx_vector_new_with_capacity(T, capacity)
- Creates a new
CnxVector(T)
with at least the given capacity and defaulted associated functions. - #define cnx_vector_new_with_capacity_and_allocator(T, capacity, allocator)
- Creates a new
CnxVector(T)
with at least the given capacity, defaulted associated functions, and provided memory allocator. - #define cnx_vector_new_with_capacity_and_collection_data(T, capacity, collection_data_ptr)
- Creates a new
CnxVector(T)
with at least the given capacity and provided associated functions. - #define cnx_vector_new_with_capacity_allocator_and_collection_data(T, capacity, allocator, collection_data_ptr)
- Creates a new
CnxVector(T)
with at least the given capacity and provided associated functions and memory allocator. - #define cnx_vector_clone(self)
- Clones the given
CnxVector(T)
- #define cnx_vector_at_mut(self, index)
- Returns a mutable reference to the element at the given
index
into the givenCnxVector(T)
- #define cnx_vector_at(self, index)
- Returns a const reference to the element at the given
index
into the givenCnxVector(T)
- #define cnx_vector_front_mut(self)
- Returns a mutable reference to the first element in the given
CnxVector(T)
- #define cnx_vector_front(self)
- Returns a const reference to the first element in the given
CnxVector(T)
- #define cnx_vector_back_mut(self)
- Returns a mutable reference to the last element in the given
CnxVector(T)
- #define cnx_vector_back(self)
- Returns a const reference to the last element in the given
CnxVector(T)
- #define cnx_vector_data_mut(self)
- Returns a pointer to the mutable raw array containing the given
CnxVector(T)
's elements. - #define cnx_vector_data(self)
- Returns a pointer to the const raw array containing the given
CnxVector(T)
's elements. - #define cnx_vector_is_empty(self)
- Returns whether the given
CnxVector(T)
is empty. - #define cnx_vector_is_full(self)
- Returns whether the given
CnxVector(T)
is full (size equals capacity) - #define cnx_vector_size(self)
- Returns the current size of the given
CnxVector(T)
- #define cnx_vector_max_size(T)
- Returns the maximum possible size of a
CnxVector(T)
containing typeT
- #define cnx_vector_capacity(self)
- Returns the current capacity of the given
CnxVector(T)
- #define cnx_vector_reserve(self, new_capacity)
- Ensures enough memory to store at least
new_capacity
number of elements in the givenCnxVector(T)
, reallocating if necessary. - #define cnx_vector_resize(self, new_size)
- Resizes the given
CnxVector(T)
tonew_size
number of elements. Ifnew_size
is greater than the current size, this will allocate memory if necessary and default-construct new elements. Ifnew_size
is less than the current size, this will destructsize - new_size
number of elements and, ifnew_size
is less than the SSO capacity, deallocate memory. - #define cnx_vector_shrink_to_fit(self)
- Shrinks the memory allocation for the given
CnxVector(T)
to match its current size. - #define cnx_vector_clear(self)
- Clears the contents of the given
CnxVector(T)
, destructing all of its elements. - #define cnx_vector_push_back(self, element)
- Appends the given element to the end of the given
CnxVector(T)
, reallocating memory if necessary. - #define cnx_vector_pop_back(self)
- Returns the last element in the given
CnxVector(T)
and removes it, if the size is greater than zero. - #define cnx_vector_pop_front(self)
- Returns the first element in the given
CnxVector(T)
and removes it, if the size is greater than zero. - #define cnx_vector_insert(self, element, index)
- Inserts the given element at the given index in the given
CnxVector(T)
, moving elements backward in the vector if necessary. - #define cnx_vector_erase(self, index)
- Removes the element at the given index from the given
CnxVector(T)
, moving elements forward in the vector if necessary. - #define cnx_vector_erase_n(self, index, num_elements)
- Removes
num_elements
elements from the givenCnxVector(T)
, starting with the element atindex
, and moving elements forward in the vector afterward, if necessary. - #define cnx_vector_free(self)
- Frees the given
CnxVector(T)
, calling the element destructor on each element and freeing any allocated memory. - #define cnx_vector_begin(self)
- Returns a
CnxRandomAccessIterator
into the mutable iteration of the givenCnxVector(T)
, starting at the beginning of the iteration (pointing at the beginning of the vector) - #define cnx_vector_end(self)
- Returns a
CnxRandomAccessIterator
into the mutable iteration of the givenCnxVector(T)
, starting at the end of the iteration (pointing at the end of the vector) - #define cnx_vector_rbegin(self)
- Returns a
CnxRandomAccessIterator
into the mutable iteration of the givenCnxVector(T)
, starting at the beginning of the reversed iteration (pointing at the end of the vector) - #define cnx_vector_rend(self)
- Returns a
CnxRandomAccessIterator
into the mutable iteration of the givenCnxVector(T)
, starting at the end of the reversed iteration (pointing at the beginning of the vector) - #define cnx_vector_iterator_equals(first, second)
- Returns whether the given pair of iterators are equal (they belong to the same collection and point to the same element), IE: if
first == second
- #define cnx_vector_cbegin(self)
- Returns a
CnxRandomAccessIterator
into the const iteration of the givenCnxVector(T)
, starting at the beginning of the iteration (pointing at the beginning of the vector) - #define cnx_vector_cend(self)
- Returns a
CnxRandomAccessIterator
into the const iteration of the givenCnxVector(T)
, starting at the end of the iteration (pointing at the end of the vector) - #define cnx_vector_crbegin(self)
- Returns a
CnxRandomAccessIterator
into the const iteration of the givenCnxVector(T)
, starting at the beginning of the reversed iteration (pointing at the end of the vector) - #define cnx_vector_crend(self)
- Returns a
CnxRandomAccessIterator
into the const iteration of the givenCnxVector(T)
, starting at the end of the reversed iteration (pointing at the beginning of the vector) - #define cnx_vector_const_iterator_equals(first, second)
- Returns whether the given pair of const iterators are equal (they belong to the same collection and point to the same element), IE: if
first == second
- #define cnx_vector_into_iter(self)
- Returns a
CnxRandomAccessIterator
into the mutable iteration of the givenCnxVector(T)
- #define cnx_vector_into_reverse_iter(self)
- Returns a
CnxRandomAccessIterator
into the mutable reversed iteration of the givenCnxVector(T)
- #define cnx_vector_into_const_iter(self)
- Returns a
CnxRandomAccessIterator
into the const iteration of the givenCnxVector(T)
- #define cnx_vector_into_reverse_const_iter(self)
- Returns a
CnxRandomAccessIterator
into the const reversed iteration of the givenCnxVector(T)
- #define CnxScopedVector(T)
- declare a
CnxVector(T)
variable with this attribute to haveCnx_vector_free
automatically called on it at scope end
Define documentation
#define cnx_vector_into_iter(self)
Returns a CnxRandomAccessIterator
into the mutable iteration of the given CnxVector(T)
Parameters | |
---|---|
self | - The CnxVector(T) to get an iterator to |
Returns | a random access iterator into the vector |
#define cnx_vector_into_reverse_iter(self)
Returns a CnxRandomAccessIterator
into the mutable reversed iteration of the given CnxVector(T)
Parameters | |
---|---|
self | - The CnxVector(T) to get an iterator to |
Returns | a random access iterator into the reversed vector |
#define cnx_vector_into_const_iter(self)
Returns a CnxRandomAccessIterator
into the const iteration of the given CnxVector(T)
Parameters | |
---|---|
self | - The CnxVector(T) to get an iterator to |
Returns | a random access iterator into the vector |
#define cnx_vector_into_reverse_const_iter(self)
Returns a CnxRandomAccessIterator
into the const reversed iteration of the given CnxVector(T)
Parameters | |
---|---|
self | - The CnxVector(T) to get an iterator to |
Returns | a random access iterator into the reversed vector |