Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
bitpit::FlatVector2D< T > Class Template Reference

Metafunction for generation of a flattened vector of vectors. More...

#include <flatVector2D.hpp>

Inheritance diagram for bitpit::FlatVector2D< T >:
Inheritance graph
[legend]

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())
 
Tback ()
 
std::size_t capacity () const
 
void clear (bool release=true)
 
void clearItems (bool release=true)
 
const Tdata () const noexcept
 
Tdata () 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)
 
Tfirst ()
 
Tget (std::size_t i)
 
const Tget (std::size_t i) const
 
std::size_t getBinarySize () const
 
TgetItem (std::size_t i, std::size_t j)
 
const TgetItem (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 ()
 
FlatVector2Doperator= (const FlatVector2D &other)=default
 
FlatVector2Doperator= (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)
 
TrawGetItem (std::size_t k)
 
const TrawGetItem (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 >
OBinaryStreamoperator<<) (OBinaryStream &buffer, const FlatVector2D< U > &vector)
 
template<class U >
IBinaryStreamoperator>>) (IBinaryStream &buffer, FlatVector2D< U > &vector)
 

Detailed Description

template<class T>
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
TThe type of the objects stored in the vector

Definition at line 59 of file flatVector2D.hpp.

Constructor & Destructor Documentation

◆ FlatVector2D() [1/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( bool initialize = true)

Default constructor.

Definition at line 75 of file flatVector2D.tpp.

◆ FlatVector2D() [2/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( const std::vector< std::size_t > & sizes,
const T & value = T() )

Creates a new container.

Parameters
sizesare the sizes of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 88 of file flatVector2D.tpp.

◆ FlatVector2D() [3/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( std::size_t nVectors,
std::size_t size,
const T & value = T() )

Creates a new container.

Parameters
nVectorsis the number of vectors
sizeis the size of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 102 of file flatVector2D.tpp.

◆ FlatVector2D() [4/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( std::size_t nVectors,
const std::size_t * sizes,
const T & value )

Creates a new container.

Parameters
nVectorsis the number of vectors
sizesare the sizes of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 116 of file flatVector2D.tpp.

◆ FlatVector2D() [5/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( std::size_t nVectors,
const std::size_t * sizes,
const T * values )

Creates a new container.

Parameters
nVectorsis the number of vectors
sizesare the sizes of the vectors
valuesare the values of the vectors

Definition at line 129 of file flatVector2D.tpp.

◆ FlatVector2D() [6/6]

template<class T >
bitpit::FlatVector2D< T >::FlatVector2D ( const std::vector< std::vector< T > > & vector2D)

Creates a new container.

Parameters
vector2Dis 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()

template<class T >
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()

template<class T >
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()

template<class T >
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
releaseif 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()

template<class T >
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
releaseif 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]

template<class T >
const T * bitpit::FlatVector2D< T >::data ( ) const
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]

template<class T >
T * bitpit::FlatVector2D< T >::data ( )
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()

template<class T >
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()

template<class T >
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()

template<class T >
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
iis the index of the vector

Definition at line 791 of file flatVector2D.tpp.

◆ eraseItem()

template<class T >
void bitpit::FlatVector2D< T >::eraseItem ( std::size_t i,
std::size_t j )

Deletes the specified item from a vector.

Parameters
iis the index of the vector
jis the index of the item that will be removed

Definition at line 806 of file flatVector2D.tpp.

◆ fill()

template<class T >
void bitpit::FlatVector2D< T >::fill ( T & value)

Sets the specified value as the value for all the items in the container.

Parameters
valueis the value to fill the container with

Definition at line 428 of file flatVector2D.tpp.

◆ first()

template<class T >
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]

template<class T >
T * bitpit::FlatVector2D< T >::get ( std::size_t i)

Gets a pointer to the first item of the specified vector.

Parameters
iis 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]

template<class T >
const T * bitpit::FlatVector2D< T >::get ( std::size_t i) const

Gets a constant pointer to the first item of the specified vector.

Parameters
iis 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()

template<class T >
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]

template<class T >
T & bitpit::FlatVector2D< T >::getItem ( std::size_t i,
std::size_t j )

Gets a reference of the specified item in a vector.

Parameters
iis the index of the vector
jis 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]

template<class T >
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
iis the index of the vector
jis 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()

template<class T >
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]

template<class T >
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]

template<class T >
std::size_t bitpit::FlatVector2D< T >::getItemCount ( std::size_t i) const

Returns the size of the specified vector.

Parameters
iis the index of the vector
Returns
The size of the vector.

Definition at line 1040 of file flatVector2D.tpp.

◆ indices() [1/2]

template<class T >
const std::size_t * bitpit::FlatVector2D< T >::indices ( ) const
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]

template<class T >
const std::size_t * bitpit::FlatVector2D< T >::indices ( std::size_t i) const
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
iis 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]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( const FlatVector2D< T > & other)

Initializes the container.

Parameters
otheris 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]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( const std::vector< std::size_t > & sizes,
const T & value = T() )

Initializes the container.

Parameters
sizesare the sizes of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 165 of file flatVector2D.tpp.

◆ initialize() [3/6]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( const std::vector< std::vector< T > > & vector2D)

Initializes the container.

Parameters
vector2Dis a 2D vector that will be used to initialize the container

Definition at line 290 of file flatVector2D.tpp.

◆ initialize() [4/6]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( std::size_t nVectors,
const std::size_t * sizes,
const T & value )

Initializes the container.

Parameters
nVectorsis the number of vectors
sizesare the sizes of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 193 of file flatVector2D.tpp.

◆ initialize() [5/6]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( std::size_t nVectors,
const std::size_t * sizes,
const T * values )

Initializes the container.

Parameters
nVectorsis the number of vectors
sizesare the sizes of the vectors
valuesare the values of the vectors

Definition at line 207 of file flatVector2D.tpp.

◆ initialize() [6/6]

template<class T >
void bitpit::FlatVector2D< T >::initialize ( std::size_t nVectors,
std::size_t size,
const T & value = T() )

Initializes the container.

Parameters
nVectorsis the number of vectors
sizeis the size of the vectors
valueis the value that will be use to initialize the items of the vectors

Definition at line 179 of file flatVector2D.tpp.

◆ isInitialized()

template<class T >
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()

template<class T >
void bitpit::FlatVector2D< T >::merge ( )

Merge the arrays together.

Definition at line 1008 of file flatVector2D.tpp.

◆ operator=() [1/2]

template<class T >
FlatVector2D & bitpit::FlatVector2D< T >::operator= ( const FlatVector2D< T > & other)
default

Copy assignment operator.

Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.

◆ operator=() [2/2]

template<class T >
FlatVector2D & bitpit::FlatVector2D< T >::operator= ( FlatVector2D< T > && other)
default

Move assignment operator.

The move assignment operator "steals" the resources held by the argument.

◆ operator==()

template<class T >
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()

template<class T >
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]

template<class T >
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]

template<class T >
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
iis the index of the vector

Definition at line 766 of file flatVector2D.tpp.

◆ pushBack() [1/4]

template<class T >
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]

template<class T >
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
subArrayis the vector that will be added

Definition at line 629 of file flatVector2D.tpp.

◆ pushBack() [3/4]

template<class T >
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
subArraySizeis the size of the vector
valueis the value to be copied (or moved) to the new item

Definition at line 612 of file flatVector2D.tpp.

◆ pushBack() [4/4]

template<class T >
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
subArraySizeis the size of the sub array
subArrayis a pointer to the sub array will be added

Definition at line 644 of file flatVector2D.tpp.

◆ pushBackItem() [1/4]

template<class T >
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
valueis the value that will be added

Definition at line 660 of file flatVector2D.tpp.

◆ pushBackItem() [2/4]

template<class T >
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
iis the index of the vector
valueis the value that will be added

Definition at line 691 of file flatVector2D.tpp.

◆ pushBackItem() [3/4]

template<class T >
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
iis the index of the vector
valueis the value that will be added

Definition at line 713 of file flatVector2D.tpp.

◆ pushBackItem() [4/4]

template<class T >
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
valueis the value that will be added

Definition at line 675 of file flatVector2D.tpp.

◆ rawGetItem() [1/2]

template<class T >
T & bitpit::FlatVector2D< T >::rawGetItem ( std::size_t k)

Gets a reference of the specified item in a vector.

Parameters
kis the raw index
Returns
A reference to the requested value.

Definition at line 933 of file flatVector2D.tpp.

◆ rawGetItem() [2/2]

template<class T >
const T & bitpit::FlatVector2D< T >::rawGetItem ( std::size_t k) const

Gets a constant reference of the specified item in a vector.

Parameters
kis the raw index
Returns
A constant reference to the requested value.

Definition at line 945 of file flatVector2D.tpp.

◆ rawSetItem() [1/2]

template<class T >
void bitpit::FlatVector2D< T >::rawSetItem ( std::size_t k,
const T & value )

Sets the value of the specified item in a vector.

Parameters
kis the raw index
valueis the value that will be set

Definition at line 909 of file flatVector2D.tpp.

◆ rawSetItem() [2/2]

template<class T >
void bitpit::FlatVector2D< T >::rawSetItem ( std::size_t k,
T && value )

Sets the value of the specified item in a vector.

Parameters
kis the raw index
valueis the value that will be set

Definition at line 921 of file flatVector2D.tpp.

◆ reserve()

template<class T >
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
nVectorsis the minimum number of vectors that the container should be able to contain
nItemsis the minimum number of items that the container should be able to contain

Definition at line 401 of file flatVector2D.tpp.

◆ setItem() [1/2]

template<class T >
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
iis the index of the vector
jis the index of the item that will be removed
valueis the value that will be set

Definition at line 826 of file flatVector2D.tpp.

◆ setItem() [2/2]

template<class T >
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
iis the index of the vector
jis the index of the item that will be removed
valueis the value that will be set

Definition at line 840 of file flatVector2D.tpp.

◆ shrinkToFit()

template<class T >
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()

template<class T >
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()

template<class T >
void bitpit::FlatVector2D< T >::swap ( FlatVector2D< T > & other)
noexcept

Swaps the contents.

Parameters
otheris another container of the same type

Definition at line 415 of file flatVector2D.tpp.

◆ vector()

template<class T >
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:
--- layout: doxygen_footer ---