Metafunction for generation of a flattened vector of vectors. More...
#include <flatVector2D.hpp>

Public Member Functions | |
FlatVector2D (bool initialize=true) | |
FlatVector2D (const FlatVector2D &other)=default | |
FlatVector2D (const std::vector< std::size_t > &sizes, const T &value=T()) | |
FlatVector2D (const std::vector< std::vector< T > > &vector2D) | |
FlatVector2D (FlatVector2D &&other)=default | |
FlatVector2D (std::size_t nVectors, const std::size_t *sizes, const T &value) | |
FlatVector2D (std::size_t nVectors, const std::size_t *sizes, const T *values) | |
FlatVector2D (std::size_t nVectors, std::size_t size, const T &value=T()) | |
T * | back () |
std::size_t | capacity () const |
void | clear (bool release=true) |
void | clearItems (bool release=true) |
const T * | data () const noexcept |
T * | data () noexcept |
void | destroy () |
bool | empty () const |
void | erase (std::size_t i) |
void | eraseItem (std::size_t i, std::size_t j) |
void | fill (T &value) |
T * | first () |
T * | get (std::size_t i) |
const T * | get (std::size_t i) const |
std::size_t | getBinarySize () const |
T & | getItem (std::size_t i, std::size_t j) |
const T & | getItem (std::size_t i, std::size_t j) const |
std::size_t | getItemCapacity () const |
std::size_t | getItemCount () const |
std::size_t | getItemCount (std::size_t i) const |
const std::size_t * | indices () const noexcept |
const std::size_t * | indices (std::size_t i) const noexcept |
void | initialize (const FlatVector2D< T > &other) |
void | initialize (const std::vector< std::size_t > &sizes, const T &value=T()) |
void | initialize (const std::vector< std::vector< T > > &vector2D) |
void | initialize (std::size_t nVectors, const std::size_t *sizes, const T &value) |
void | initialize (std::size_t nVectors, const std::size_t *sizes, const T *values) |
void | initialize (std::size_t nVectors, std::size_t size, const T &value=T()) |
bool | isInitialized () const |
void | merge () |
FlatVector2D & | operator= (const FlatVector2D &other)=default |
FlatVector2D & | operator= (FlatVector2D &&other)=default |
bool | operator== (const FlatVector2D &rhs) const |
void | popBack () |
void | popBackItem () |
void | popBackItem (std::size_t i) |
void | pushBack () |
void | pushBack (const std::vector< T > &subArray) |
void | pushBack (std::size_t subArraySize, const T &value=T()) |
void | pushBack (std::size_t subArraySize, const T *subArray) |
void | pushBackItem (const T &value) |
void | pushBackItem (std::size_t i, const T &value) |
void | pushBackItem (std::size_t i, T &&value) |
void | pushBackItem (T &&value) |
T & | rawGetItem (std::size_t k) |
const T & | rawGetItem (std::size_t k) const |
void | rawSetItem (std::size_t k, const T &value) |
void | rawSetItem (std::size_t k, T &&value) |
void | reserve (std::size_t nVectors, std::size_t nItems=0) |
void | setItem (std::size_t i, std::size_t j, const T &value) |
void | setItem (std::size_t i, std::size_t j, T &&value) |
void | shrinkToFit () |
std::size_t | size () const |
void | swap (FlatVector2D &other) noexcept |
const std::vector< T > & | vector () const |
Friends | |
template<class U> | |
OBinaryStream & | operator<<) (OBinaryStream &buffer, const FlatVector2D< U > &vector) |
template<class U> | |
IBinaryStream & | operator>>) (IBinaryStream &buffer, FlatVector2D< U > &vector) |
Detailed Description
class bitpit::FlatVector2D< T >
Metafunction for generation of a flattened vector of vectors.
Usage: Use FlatVector2D<Type>
to declare a flattened vector of vectors.
- Template Parameters
-
T The type of the objects stored in the vector
Definition at line 59 of file flatVector2D.hpp.
Constructor & Destructor Documentation
◆ FlatVector2D() [1/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | bool | initialize = true | ) |
Default constructor.
Definition at line 75 of file flatVector2D.tpp.
◆ FlatVector2D() [2/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | const std::vector< std::size_t > & | sizes, |
const T & | value = T() ) |
Creates a new container.
- Parameters
-
sizes are the sizes of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 88 of file flatVector2D.tpp.
◆ FlatVector2D() [3/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | std::size_t | nVectors, |
std::size_t | size, | ||
const T & | value = T() ) |
Creates a new container.
- Parameters
-
nVectors is the number of vectors size is the size of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 102 of file flatVector2D.tpp.
◆ FlatVector2D() [4/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | std::size_t | nVectors, |
const std::size_t * | sizes, | ||
const T & | value ) |
Creates a new container.
- Parameters
-
nVectors is the number of vectors sizes are the sizes of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 116 of file flatVector2D.tpp.
◆ FlatVector2D() [5/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | std::size_t | nVectors, |
const std::size_t * | sizes, | ||
const T * | values ) |
Creates a new container.
- Parameters
-
nVectors is the number of vectors sizes are the sizes of the vectors values are the values of the vectors
Definition at line 129 of file flatVector2D.tpp.
◆ FlatVector2D() [6/6]
bitpit::FlatVector2D< T >::FlatVector2D | ( | const std::vector< std::vector< T > > & | vector2D | ) |
Creates a new container.
- Parameters
-
vector2D is a 2D vector that will be used to initialize the newly created container
Definition at line 141 of file flatVector2D.tpp.
Member Function Documentation
◆ back()
T * bitpit::FlatVector2D< T >::back | ( | ) |
Gets a pointer to the first item of the last vector.
- Returns
- A pointer to the first item of the vector.
Definition at line 956 of file flatVector2D.tpp.
◆ capacity()
std::size_t bitpit::FlatVector2D< T >::capacity | ( | ) | const |
Returns the size of the storage space currently allocated for storing vectors, expressed in terms of items.
- Returns
- The size of the storage space currently allocated for storing vectors, expressed in terms of items.
Definition at line 995 of file flatVector2D.tpp.
◆ clear()
void bitpit::FlatVector2D< T >::clear | ( | bool | release = true | ) |
Clears content.
Removes all items from the container (which are destroyed), leaving the container with a size of 0.
- Parameters
-
release if it's true the memory hold by the container will be released, otherwise the container will be cleared but its memory will not be relased
Definition at line 466 of file flatVector2D.tpp.
◆ clearItems()
void bitpit::FlatVector2D< T >::clearItems | ( | bool | release = true | ) |
Clears the items.
Removes all items stored in the vectors (which are destroyed), leaving each vector with a size of 0.
- Parameters
-
release if it's true the memory hold by the container will be released, otherwise the container will be cleared but its memory will not be relased
Definition at line 491 of file flatVector2D.tpp.
◆ data() [1/2]
|
noexcept |
Returns a direct constant pointer to the memory vector used internally by the container to store its items.
- Returns
- A constant pointer to the first item in the vector used internally by the container.
Definition at line 569 of file flatVector2D.tpp.
◆ data() [2/2]
|
noexcept |
Returns a direct pointer to the memory vector used internally by the container to store its items.
- Returns
- A pointer to the first item in the vector used internally by the container.
Definition at line 555 of file flatVector2D.tpp.
◆ destroy()
void bitpit::FlatVector2D< T >::destroy | ( | ) |
Destroy the container.
After calling this function the container will be non-functional until it is re-initialized.
Definition at line 361 of file flatVector2D.tpp.
◆ empty()
bool bitpit::FlatVector2D< T >::empty | ( | ) | const |
Tests whether the container is empty.
- Returns
- true if the container size is 0, false otherwise.
Definition at line 450 of file flatVector2D.tpp.
◆ erase()
void bitpit::FlatVector2D< T >::erase | ( | std::size_t | i | ) |
Deletes specified vector.
Removes from the container the specified vector, effectively reducing the container size by one.
- Parameters
-
i is the index of the vector
Definition at line 791 of file flatVector2D.tpp.
◆ eraseItem()
void bitpit::FlatVector2D< T >::eraseItem | ( | std::size_t | i, |
std::size_t | j ) |
Deletes the specified item from a vector.
- Parameters
-
i is the index of the vector j is the index of the item that will be removed
Definition at line 806 of file flatVector2D.tpp.
◆ fill()
void bitpit::FlatVector2D< T >::fill | ( | T & | value | ) |
Sets the specified value as the value for all the items in the container.
- Parameters
-
value is the value to fill the container with
Definition at line 428 of file flatVector2D.tpp.
◆ first()
T * bitpit::FlatVector2D< T >::first | ( | ) |
Gets a pointer to the first item of the first vector.
- Returns
- A pointer to the first item of the vector.
Definition at line 967 of file flatVector2D.tpp.
◆ get() [1/2]
T * bitpit::FlatVector2D< T >::get | ( | std::size_t | i | ) |
Gets a pointer to the first item of the specified vector.
- Parameters
-
i is the index of the vector
- Returns
- A pointer to the first item of the specified vector.
Definition at line 895 of file flatVector2D.tpp.
◆ get() [2/2]
const T * bitpit::FlatVector2D< T >::get | ( | std::size_t | i | ) | const |
Gets a constant pointer to the first item of the specified vector.
- Parameters
-
i is the index of the vector
- Returns
- A constant pointer to the first item of the specified vector.
Definition at line 881 of file flatVector2D.tpp.
◆ getBinarySize()
size_t bitpit::FlatVector2D< T >::getBinarySize | ( | ) | const |
Returns the buffer size (in bytes) required to store the container.
- Returns
- The buffer size (in bytes) required to store the container.
Definition at line 1068 of file flatVector2D.tpp.
◆ getItem() [1/2]
T & bitpit::FlatVector2D< T >::getItem | ( | std::size_t | i, |
std::size_t | j ) |
Gets a reference of the specified item in a vector.
- Parameters
-
i is the index of the vector j is the index of the item that will be removed
- Returns
- A reference to the requested value.
Definition at line 854 of file flatVector2D.tpp.
◆ getItem() [2/2]
const T & bitpit::FlatVector2D< T >::getItem | ( | std::size_t | i, |
std::size_t | j ) const |
Gets a constant reference of the specified item in a vector.
- Parameters
-
i is the index of the vector j is the index of the item that will be removed
- Returns
- A constant reference to the requested value.
Definition at line 868 of file flatVector2D.tpp.
◆ getItemCapacity()
std::size_t bitpit::FlatVector2D< T >::getItemCapacity | ( | ) | const |
Returns the size of the storage space currently allocated for storing vectors items, expressed in terms of items.
- Returns
- The size of the storage space currently allocated for storing vectors items, expressed in terms of items.
Definition at line 1057 of file flatVector2D.tpp.
◆ getItemCount() [1/2]
std::size_t bitpit::FlatVector2D< T >::getItemCount | ( | ) | const |
Returns the total size of all the vectors.
- Returns
- The total size of all the vectors.
Definition at line 1024 of file flatVector2D.tpp.
◆ getItemCount() [2/2]
std::size_t bitpit::FlatVector2D< T >::getItemCount | ( | std::size_t | i | ) | const |
Returns the size of the specified vector.
- Parameters
-
i is the index of the vector
- Returns
- The size of the vector.
Definition at line 1040 of file flatVector2D.tpp.
◆ indices() [1/2]
|
noexcept |
Returns a constant pointer to the first item in the vector used internally by the container to store the indices.
- Returns
- A constant pointer to the first item in the vector used internally by the container to store the indices.
Definition at line 525 of file flatVector2D.tpp.
◆ indices() [2/2]
|
noexcept |
Returns a constant pointer to the first item in the vector used internally by the container to store the indices of the specified vector.
- Parameters
-
i is the index of the vector
- Returns
- A constant pointer to the first item in the vector used internally by the container to store the indices of the specified vector.
Definition at line 541 of file flatVector2D.tpp.
◆ initialize() [1/6]
void bitpit::FlatVector2D< T >::initialize | ( | const FlatVector2D< T > & | other | ) |
Initializes the container.
- Parameters
-
other is antoher container of the same type, whose contents will be used to initialize the current container
Definition at line 348 of file flatVector2D.tpp.
◆ initialize() [2/6]
void bitpit::FlatVector2D< T >::initialize | ( | const std::vector< std::size_t > & | sizes, |
const T & | value = T() ) |
Initializes the container.
- Parameters
-
sizes are the sizes of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 165 of file flatVector2D.tpp.
◆ initialize() [3/6]
void bitpit::FlatVector2D< T >::initialize | ( | const std::vector< std::vector< T > > & | vector2D | ) |
Initializes the container.
- Parameters
-
vector2D is a 2D vector that will be used to initialize the container
Definition at line 290 of file flatVector2D.tpp.
◆ initialize() [4/6]
void bitpit::FlatVector2D< T >::initialize | ( | std::size_t | nVectors, |
const std::size_t * | sizes, | ||
const T & | value ) |
Initializes the container.
- Parameters
-
nVectors is the number of vectors sizes are the sizes of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 193 of file flatVector2D.tpp.
◆ initialize() [5/6]
void bitpit::FlatVector2D< T >::initialize | ( | std::size_t | nVectors, |
const std::size_t * | sizes, | ||
const T * | values ) |
Initializes the container.
- Parameters
-
nVectors is the number of vectors sizes are the sizes of the vectors values are the values of the vectors
Definition at line 207 of file flatVector2D.tpp.
◆ initialize() [6/6]
void bitpit::FlatVector2D< T >::initialize | ( | std::size_t | nVectors, |
std::size_t | size, | ||
const T & | value = T() ) |
Initializes the container.
- Parameters
-
nVectors is the number of vectors size is the size of the vectors value is the value that will be use to initialize the items of the vectors
Definition at line 179 of file flatVector2D.tpp.
◆ isInitialized()
bool bitpit::FlatVector2D< T >::isInitialized | ( | ) | const |
Check if the container has been initialized.
- Returns
- Returns true if the container has been initialized, false otherwise.
Definition at line 152 of file flatVector2D.tpp.
◆ merge()
void bitpit::FlatVector2D< T >::merge | ( | ) |
Merge the arrays together.
Definition at line 1008 of file flatVector2D.tpp.
◆ operator=() [1/2]
|
default |
Copy assignment operator.
Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.
◆ operator=() [2/2]
|
default |
Move assignment operator.
The move assignment operator "steals" the resources held by the argument.
◆ operator==()
bool bitpit::FlatVector2D< T >::operator== | ( | const FlatVector2D< T > & | rhs | ) | const |
Tests whether two containers are equal.
- Returns
- true if the containers are equal, false otherwise.
Definition at line 439 of file flatVector2D.tpp.
◆ popBack()
void bitpit::FlatVector2D< T >::popBack | ( | ) |
Deletes last vector.
Removes the last vector in the container, effectively reducing the container size by one.
Definition at line 732 of file flatVector2D.tpp.
◆ popBackItem() [1/2]
void bitpit::FlatVector2D< T >::popBackItem | ( | ) |
Deletes last item from last vector.
Removes the last item from the last vector in the container.
Definition at line 748 of file flatVector2D.tpp.
◆ popBackItem() [2/2]
void bitpit::FlatVector2D< T >::popBackItem | ( | std::size_t | i | ) |
Deletes last item from specified vector.
Removes the last item from the specified vector in the container.
- Parameters
-
i is the index of the vector
Definition at line 766 of file flatVector2D.tpp.
◆ pushBack() [1/4]
void bitpit::FlatVector2D< T >::pushBack | ( | ) |
Adds an empty vector at the end.
Adds an empty vector at the end of the container, after its current last vector.
Definition at line 595 of file flatVector2D.tpp.
◆ pushBack() [2/4]
void bitpit::FlatVector2D< T >::pushBack | ( | const std::vector< T > & | subArray | ) |
Adds the specified vector at the end.
Adds the specified vector at the end of the vector, after its current last item.
- Parameters
-
subArray is the vector that will be added
Definition at line 629 of file flatVector2D.tpp.
◆ pushBack() [3/4]
void bitpit::FlatVector2D< T >::pushBack | ( | std::size_t | subArraySize, |
const T & | value = T() ) |
Adds a vector with the specified size at the end.
Adds a vector with the specified size at the end of the vector, after its current last item. The content of value is copied (or moved) to the new vector.
- Parameters
-
subArraySize is the size of the vector value is the value to be copied (or moved) to the new item
Definition at line 612 of file flatVector2D.tpp.
◆ pushBack() [4/4]
void bitpit::FlatVector2D< T >::pushBack | ( | std::size_t | subArraySize, |
const T * | subArray ) |
Adds the specified array at the end.
Adds the specified array at the end of the vector, after its current last item.
- Parameters
-
subArraySize is the size of the sub array subArray is a pointer to the sub array will be added
Definition at line 644 of file flatVector2D.tpp.
◆ pushBackItem() [1/4]
void bitpit::FlatVector2D< T >::pushBackItem | ( | const T & | value | ) |
Adds an item to the last vector.
Adds an item at the end of to the last vector.
- Parameters
-
value is the value that will be added
Definition at line 660 of file flatVector2D.tpp.
◆ pushBackItem() [2/4]
void bitpit::FlatVector2D< T >::pushBackItem | ( | std::size_t | i, |
const T & | value ) |
Adds an item to the specified vector.
Adds an item at the end of to the specified last vector.
- Parameters
-
i is the index of the vector value is the value that will be added
Definition at line 691 of file flatVector2D.tpp.
◆ pushBackItem() [3/4]
void bitpit::FlatVector2D< T >::pushBackItem | ( | std::size_t | i, |
T && | value ) |
Adds an item to the specified vector.
Adds an item at the end of to the specified last vector.
- Parameters
-
i is the index of the vector value is the value that will be added
Definition at line 713 of file flatVector2D.tpp.
◆ pushBackItem() [4/4]
void bitpit::FlatVector2D< T >::pushBackItem | ( | T && | value | ) |
Adds an item to the last vector.
Adds an item at the end of to the last vector.
- Parameters
-
value is the value that will be added
Definition at line 675 of file flatVector2D.tpp.
◆ rawGetItem() [1/2]
T & bitpit::FlatVector2D< T >::rawGetItem | ( | std::size_t | k | ) |
Gets a reference of the specified item in a vector.
- Parameters
-
k is the raw index
- Returns
- A reference to the requested value.
Definition at line 933 of file flatVector2D.tpp.
◆ rawGetItem() [2/2]
const T & bitpit::FlatVector2D< T >::rawGetItem | ( | std::size_t | k | ) | const |
Gets a constant reference of the specified item in a vector.
- Parameters
-
k is the raw index
- Returns
- A constant reference to the requested value.
Definition at line 945 of file flatVector2D.tpp.
◆ rawSetItem() [1/2]
void bitpit::FlatVector2D< T >::rawSetItem | ( | std::size_t | k, |
const T & | value ) |
Sets the value of the specified item in a vector.
- Parameters
-
k is the raw index value is the value that will be set
Definition at line 909 of file flatVector2D.tpp.
◆ rawSetItem() [2/2]
void bitpit::FlatVector2D< T >::rawSetItem | ( | std::size_t | k, |
T && | value ) |
Sets the value of the specified item in a vector.
- Parameters
-
k is the raw index value is the value that will be set
Definition at line 921 of file flatVector2D.tpp.
◆ reserve()
void bitpit::FlatVector2D< T >::reserve | ( | std::size_t | nVectors, |
std::size_t | nItems = 0 ) |
Requests a change in capacity.
Requests that the collpased-vector capacity be at least enough to contain nVectors vectors and nItems items.
- Parameters
-
nVectors is the minimum number of vectors that the container should be able to contain nItems is the minimum number of items that the container should be able to contain
Definition at line 401 of file flatVector2D.tpp.
◆ setItem() [1/2]
void bitpit::FlatVector2D< T >::setItem | ( | std::size_t | i, |
std::size_t | j, | ||
const T & | value ) |
Sets the value of the specified item in a vector.
- Parameters
-
i is the index of the vector j is the index of the item that will be removed value is the value that will be set
Definition at line 826 of file flatVector2D.tpp.
◆ setItem() [2/2]
void bitpit::FlatVector2D< T >::setItem | ( | std::size_t | i, |
std::size_t | j, | ||
T && | value ) |
Sets the value of the specified item in a vector.
- Parameters
-
i is the index of the vector j is the index of the item that will be removed value is the value that will be set
Definition at line 840 of file flatVector2D.tpp.
◆ shrinkToFit()
void bitpit::FlatVector2D< T >::shrinkToFit | ( | ) |
Shrinks to fit
Requests the container to reduce its capacity to fit its size.
Definition at line 511 of file flatVector2D.tpp.
◆ size()
std::size_t bitpit::FlatVector2D< T >::size | ( | ) | const |
Returns the number of vectors in the container
- Returns
- The number of vectors in the container.
Definition at line 978 of file flatVector2D.tpp.
◆ swap()
|
noexcept |
Swaps the contents.
- Parameters
-
other is another container of the same type
Definition at line 415 of file flatVector2D.tpp.
◆ vector()
const std::vector< T > & bitpit::FlatVector2D< T >::vector | ( | ) | const |
Returns a constant reference to the vector used internally by the container to store its items.
- Returns
- A constant reference to the vector used internally by the container.
Definition at line 583 of file flatVector2D.tpp.
The documentation for this class was generated from the following files:
- src/containers/flatVector2D.hpp
- src/containers/flatVector2D.tpp
