Array related functions include vector and pointer array. More...
Classes | |
| class | Array2D |
| Rudimentary RAII class of 2D Array which occupy successive memory. More... | |
Functions | |
| void | Output1DArrayToTxtFile (int n, const float *data, const char *filename) |
| Write 1D array to a file. More... | |
| void | Output2DArrayToTxtFile (int rows, int cols, const float **data, const char *filename) |
| Write 2D array to a file. More... | |
| template<typename T > | |
| void | Read1DArrayFromTxtFile (const char *filename, int &rows, T *&data) |
| Read 1D array from file The input file should follow the format: a 1D array sized rows * 1. More... | |
| template<typename T > | |
| void | Read2DArrayFromTxtFile (const char *filename, int &rows, T **&data) |
| Read 2D array from file The input file should follow the format: a 2D array sized rows * rows. More... | |
| template<typename T > | |
| void | Read2DArrayFromString (const char *s, int &rows, T **&data) |
| Read 2D array from string The input string should follow the format: float value, total number is rows * rows. More... | |
| template<typename T , typename INI_T > | |
| bool | Initialize1DArray (int row, T *&data, INI_T init_value) |
| Initialize DT_Array1D data. More... | |
| template<typename T , typename INI_T > | |
| bool | Initialize1DArray (int row, T *&data, INI_T *init_data) |
| Initialize DT_Array1D data based on an existed array. More... | |
| template<typename T , typename INI_T > | |
| bool | Initialize1DArray4ItpWeight (int row, T *&data, INI_T *init_data, int itp_weight_data_length) |
| template<typename T , typename INI_T > | |
| bool | Initialize2DArray (int row, int col, T **&data, INI_T init_value) |
| Initialize DT_Array2D data. More... | |
| template<typename T , typename INI_T > | |
| bool | Initialize2DArray (int row, int col, T **&data, INI_T **init_data) |
Initialize DT_Array2D data based on an existed array The usage of const T * const * is refers to http://blog.csdn.net/pmt123456/article/details/50813564. More... | |
| template<typename T1 , typename T2 > | |
| bool | Initialize2DArray (T1 *init_data, int &rows, int &max_cols, T2 **&data) |
| Initialize irregular DT_Array2D data based on an existed 1D array. More... | |
| template<typename T > | |
| void | Release1DArray (T *&data) |
| Release DT_Array1D data. More... | |
| template<typename T > | |
| void | Release2DArray (T **&data) |
| Release DT_Array2D data. More... | |
| template<typename T > | |
| void | BatchRelease1DArray (T *&data,...) |
Batch release of 1D array Variable arguments with the end of nullptr. More... | |
| template<typename T > | |
| void | BatchRelease2DArray (int nrows, T **&data,...) |
| Batch release of 2D array,. More... | |
| template<typename T > | |
| bool | Read2DArrayFromCsvFile (const char *filename, const vector< string > *header, std::vector< std::vector< T > > &data) |
| Read csv. More... | |
| template<typename T > | |
| bool | ValueInVector (T val, const vector< T > &vec) |
| If value in vector container. More... | |
| template<typename T > | |
| void | RemoveValueInVector (T val, vector< T > &vec) |
| Remove value in vector container. More... | |
Array related functions include vector and pointer array.
| void ccgl::utils_array::BatchRelease1DArray | ( | T *& | data, |
| ... | |||
| ) |
Batch release of 1D array Variable arguments with the end of nullptr.
The input parameters are listed as data, data2, ... , dataN, and ended with nullptr.
Example:
USE WITH ALL CAUTIONS CLEARLY AWARED.
| void ccgl::utils_array::BatchRelease2DArray | ( | int | nrows, |
| T **& | data, | ||
| ... | |||
| ) |
Batch release of 2D array,.
Example:
| [in] | nrows | Rows |
| [in] | data | The input parameters are listed as data, data2, ... , dataN, and ended with nullptr. |
| bool ccgl::utils_array::Initialize1DArray | ( | int | row, |
| T *& | data, | ||
| INI_T * | init_data | ||
| ) |
Initialize DT_Array1D data based on an existed array.
| [in] | row | |
| [in] | data | |
| [in] | init_data |
| bool ccgl::utils_array::Initialize1DArray | ( | int | row, |
| T *& | data, | ||
| INI_T | init_value | ||
| ) |
Initialize DT_Array1D data.
| [in] | row | |
| [in] | data | |
| [in] | init_value |
| bool ccgl::utils_array::Initialize2DArray | ( | int | row, |
| int | col, | ||
| T **& | data, | ||
| INI_T ** | init_data | ||
| ) |
Initialize DT_Array2D data based on an existed array The usage of const T * const * is refers to http://blog.csdn.net/pmt123456/article/details/50813564.
| [in] | row | |
| [in] | col | |
| [in] | data | |
| [in] | init_data | dimension MUST BE (row, col) |
| bool ccgl::utils_array::Initialize2DArray | ( | int | row, |
| int | col, | ||
| T **& | data, | ||
| INI_T | init_value | ||
| ) |
Initialize DT_Array2D data.
The 2D array are created in a successive memory.
Refers to https://stackoverflow.com/a/21944048/4837280
| [in] | row | |
| [in] | col | |
| [in] | data | |
| [in] | init_value |
| bool ccgl::utils_array::Initialize2DArray | ( | T1 * | init_data, |
| int & | rows, | ||
| int & | max_cols, | ||
| T2 **& | data | ||
| ) |
Initialize irregular DT_Array2D data based on an existed 1D array.
| [in] | init_data | Initial 1D array |
| [out] | rows | Rows count |
| [out] | max_cols | Maximum cols count |
| [out] | data | Irregular 2D array |
| void ccgl::utils_array::Output1DArrayToTxtFile | ( | int | n, |
| const float * | data, | ||
| const char * | filename | ||
| ) |
Write 1D array to a file.
| [in] | n,data,filename |
| void ccgl::utils_array::Output2DArrayToTxtFile | ( | int | rows, |
| int | cols, | ||
| const float ** | data, | ||
| const char * | filename | ||
| ) |
Write 2D array to a file.
| [in] | rows,cols,data,filename |
| void ccgl::utils_array::Read1DArrayFromTxtFile | ( | const char * | filename, |
| int & | rows, | ||
| T *& | data | ||
| ) |
Read 1D array from file The input file should follow the format: a 1D array sized rows * 1.
The size of data is rows
| [in] | filename | |
| [out] | rows,data |
| bool ccgl::utils_array::Read2DArrayFromCsvFile | ( | const char * | filename, |
| const vector< string > * | header, | ||
| std::vector< std::vector< T > > & | data | ||
| ) |
Read csv.
| [in] | filename | |
| [in] | header | Only the columns in the header will be read and stored in data. The order of the data is the same as the header. |
| [out] | data |
| void ccgl::utils_array::Read2DArrayFromString | ( | const char * | s, |
| int & | rows, | ||
| T **& | data | ||
| ) |
Read 2D array from string The input string should follow the format: float value, total number is rows * rows.
The size of data is rows * (rows + 1), the first element of each row is the rows.
| [in] | s | |
| [out] | rows,data |
| void ccgl::utils_array::Read2DArrayFromTxtFile | ( | const char * | filename, |
| int & | rows, | ||
| T **& | data | ||
| ) |
Read 2D array from file The input file should follow the format: a 2D array sized rows * rows.
The size of data is rows * (rows + 1), the first element of each row is the rows
| [in] | filename | |
| [out] | rows,data |
| void ccgl::utils_array::Release1DArray | ( | T *& | data | ) |
Release DT_Array1D data.
| [in] | data |
| void ccgl::utils_array::Release2DArray | ( | T **& | data | ) |
Release DT_Array2D data.
| [in] | data |
| void ccgl::utils_array::RemoveValueInVector | ( | T | val, |
| vector< T > & | vec | ||
| ) |
Remove value in vector container.
| [in] | val | Value to be removed, e.g., a int, or float |
| [in] | vec | Vector container, data type is consistent with val |
| bool ccgl::utils_array::ValueInVector | ( | T | val, |
| const vector< T > & | vec | ||
| ) |
If value in vector container.
| [in] | val | Value, e.g., a int, or float |
| [in] | vec | Vector container, data type is consistent with val |