utils_array.h File Reference

Template functions to initialize and release arrays. More...

#include <new>
#include <cstdarg>
#include <iostream>
#include <vector>
#include "basic.h"

Go to the source code of this file.

Classes

class  ccgl::utils_array::Array2D< T >
 Rudimentary RAII class of 2D Array which occupy successive memory. More...
 

Namespaces

namespace  ccgl
 Common Cross-platform Geographic Library (CCGL)
 
namespace  ccgl::utils_array
 Array related functions include vector and pointer array.
 

Functions

template<typename T , typename INI_T >
bool ccgl::utils_array::Initialize1DArray (int row, T *&data, INI_T init_value)
 Initialize DT_Array1D data. More...
 
template<typename T , typename INI_T >
bool ccgl::utils_array::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 ccgl::utils_array::Initialize1DArray4ItpWeight (int row, T *&data, INI_T *init_data, int itp_weight_data_length)
 
template<typename T , typename INI_T >
bool ccgl::utils_array::Initialize2DArray (int row, int col, T **&data, INI_T init_value)
 Initialize DT_Array2D data. More...
 
template<typename T , typename INI_T >
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. More...
 
template<typename T1 , typename T2 >
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. More...
 
template<typename T >
void ccgl::utils_array::Release1DArray (T *&data)
 Release DT_Array1D data. More...
 
template<typename T >
void ccgl::utils_array::Release2DArray (T **&data)
 Release DT_Array2D data. More...
 
template<typename T >
void ccgl::utils_array::BatchRelease1DArray (T *&data,...)
 Batch release of 1D array Variable arguments with the end of nullptr. More...
 
template<typename T >
void ccgl::utils_array::BatchRelease2DArray (int nrows, T **&data,...)
 Batch release of 2D array,. More...
 
void ccgl::utils_array::Output1DArrayToTxtFile (int n, const float *data, const char *filename)
 Write 1D array to a file. More...
 
void ccgl::utils_array::Output2DArrayToTxtFile (int rows, int cols, const float **data, const char *filename)
 Write 2D array to a file. More...
 
template<typename T >
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. More...
 
template<typename T >
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. More...
 
template<typename T >
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. More...
 
template<typename T >
bool ccgl::utils_array::ValueInVector (T val, const vector< T > &vec)
 If value in vector container. More...
 
template<typename T >
void ccgl::utils_array::RemoveValueInVector (T val, vector< T > &vec)
 Remove value in vector container. More...
 

Detailed Description

Template functions to initialize and release arrays.

Remarks
  • 1. 2018-05-02 - lj - Make part of CCGL.
  • 2. 2021-07-20 - lj - Initialize 2D array in a succesive memory.
Author
Liangjun Zhu, zlj(at)lreis.ac.cn
Version
1.1