Main Page · Modules · All Classes · Class Hierarchy
Classes | Macros | Enumerations | Functions
Mindcommon

Classes

class  MCBinaryData
 Binary data class. More...
 
struct  MCDataItemBase
 Data container item base structure to store basic type info. More...
 
class  MCDataItem< T >
 A helper class to fill the type info to the base structure. More...
 
class  MCDataContainer
 Data container. More...
 
class  MCDataStorage
 Data storage with file support. More...
 
struct  iterator_extractor< T >
 Iterator magic for for loops to get the index while iterating through. More...
 
struct  iterator_extractor< T const >
 Iterator magic for for loops to get the index while iterating through. More...
 
class  Indexer< T >
 Iterator magic for for loops to get the index while iterating through. More...
 
class  MCRandomSeed
 Random seed generation based on boost::mt19937. More...
 
class  MCDiffPatch
 Diff-patch class. More...
 
class  MCLog
 Basic log functionalities. More...
 
class  MCLogMessageHandler
 Log message handler. More...
 
class  MCLogEcho
 Simple class to echo the log messages to the console. More...
 
class  MCQtLogEcho
 Simple class to echo the log messages to the Qt debug console. More...
 
class  MCThreadLocalData< T >
 A wrapper class to cover boost::thread_specific_ptr/folly::ThreadLocal API on certain targets. More...
 
class  MCTimer
 Simple timer class with microsecond precision. More...
 
class  MASystemTimeHandler
 System timer handler. More...
 
class  MCZipper
 Compression class. More...
 

Macros

#define foreach_i(_i, _iter, _container)
 For each cycle with auto keyword and index values.
 
#define MC_DIR_SEPARATOR   "/"
 Directory separator macro.
 
#define MC_UNUSED(a)   (void)a;
 Helper macro to avoid compiler warning about unused function parameters.
 
#define MC_DISABLE_COPY(class_name)
 Helper macro to disable the copy constructor and assignment operator of a class (object copying)
 
#define MC_DISABLE_DEFAULT_CTOR(class_name)
 Helper macro to disable the default constructor of a class.
 
#define MC_LOG(...)   MCLog::LogMessage(__PRETTY_FUNCTION__, __VA_ARGS__)
 Debug macro.
 
#define MC_WARNING(...)   MCLog::WarningMessage(__PRETTY_FUNCTION__, __VA_ARGS__)
 Warning macro.
 
#define MC_ERROR(...)   MCLog::ErrorMessage(__PRETTY_FUNCTION__, __VA_ARGS__)
 Error macro.
 
#define MC_BPRINT(color, ...)   MCLog::FormattedMessage(color, true, __VA_ARGS__)
 Print macro with bold letters.
 
#define MC_PRINT(color, ...)   MCLog::FormattedMessage(color, false, __VA_ARGS__)
 Print macro with normal letters.
 
#define MC_NPRINT(...)   MCLog::FormattedMessage(MCLog::NoColor, false, __VA_ARGS__)
 Print macro with normal letters without colors.
 

Enumerations

Functions

template<typename T , typename U >
const T MCMin (const U &container)
 Get the minimal value of a container. More...
 
template<typename T , typename U >
const T MCMax (const U &container)
 Get the maximal value of a container. More...
 
QStringList MCStdStringsToQStringList (const MC::StringList &string_list)
 Convert a std::string vector to QStringList. More...
 
MC::StringList MCQStringListToStdStrings (const QStringList &string_list)
 Convert a QStringList to std::string vector. More...
 
template<typename T >
std::vector< std::vector< T > > MCQVectorTableToStdVectorTable (const QVector< QVector< T > > &table)
 Convert QVector based table to std::vector based table. More...
 
template<typename T , typename U >
int MCGetQMapKeyIndex (const QMap< T, U > &container, const T &key)
 Get the index of a key in a QMap. More...
 
template<typename T , typename U >
MCGetQMapItemByIndex (const QMap< T, U > &container, const int index)
 Get a certain item from a QMap. More...
 
template<typename T , typename U >
QMap< T, U >::const_iterator MCGetQMapConstIteratorByIndex (const QMap< T, U > &container, const int index)
 Get the iterator for a certain item from a QMap. More...
 
template<typename T , typename U >
QMap< T, U >::iterator MCGetQMapIteratorByIndex (QMap< T, U > &container, const int index)
 Get the iterator for a certain item from a QMap. More...
 
template<typename T , typename U >
std::pair< int, T > MCBinarySearch (const U &container, const T &value, bool nearest=false)
 Binary search for a value in a container. More...
 
template<typename T , typename U >
std::pair< int, T > MCBinarySearch (const U &container, const T &value, int min_index, int max_index, bool nearest=false)
 Binary search for a value in a certain range of a container. More...
 
template<typename T >
std::pair< int, T > MCBinarySearch (const std::vector< T > &container, const T &value, bool nearest=false)
 Binary search for a value in a vector. More...
 
template<typename T >
std::pair< int, T > MCBinarySearch (const std::vector< T > &container, const T &value, int min_index, int max_index, bool nearest=false)
 Binary search for a value in a certain range of a vector. More...
 
template<typename T , typename U >
std::vector< T > MCGetContainerKeys (const U &container)
 Get container keys as a vector. More...
 
template<typename T , typename U >
std::vector< T > MCGetContainerValues (const U &container)
 Get container values as a vector. More...
 
template<typename T , typename U >
bool MCContainerContains (const U &container, const T &value)
 Check if a container contains a value. More...
 
template<typename T , typename U >
void MCMultiplyContainer (U &container, T multiplier)
 Multiple a container by a value. More...
 
template<typename T , typename U >
void MCSumContainers (U &target_container, const U &second_container, T multiplier)
 Summarize containers. More...
 
template<typename T , typename U >
MCGetMostFrequentItemFromContainer (const U &container)
 Get the most frequent item of a container. More...
 
template<typename V >
bool MCIsConsistentTable (V &table)
 Check the consistency of a table. More...
 
template<typename T , typename U >
void MCShiftContainerbyValue (U &container, T shift_value)
 Shift container values. More...
 
template<typename T , typename V >
void MCAddValueToTable (V &table, T value)
 Add value to table items. More...
 
template<typename T , typename V >
void MCMultiplyTableRow (V &table, unsigned int row_index, T multiplier)
 Multiple table row by a value. More...
 
template<typename T , typename V >
void MCMultiplyTableColumn (V &table, unsigned int column_index, T multiplier)
 Multiple table column by a value. More...
 
template<typename T , typename V >
void MCMultiplyTable (V &table, T multiplier)
 Multiply table by value. More...
 
template<typename T , typename V >
void MCSumTables (V &target_table, const V &second_table, T multiplier)
 Summarize tables. More...
 
template<typename T , typename V >
void MCSwapTableColumns (V &table, unsigned int column1, unsigned int column2)
 Swap two columns inside a table. More...
 
template<typename T , typename U , typename V >
MCDiagonalItemsFromTable (const V &table, bool top_left_to_right_bottom=true)
 Get the diagonal items of a squared table. More...
 
template<typename U >
void MCMergeContainers (U &target, const U &other)
 Merge two containers. More...
 
template<typename T , typename U >
std::vector< int > MCItemIndicesInContainer (const U &container, const T item)
 Get item indices in a container. More...
 
template<typename T , typename U >
std::vector< T > MCItemsByIndicesFromContainer (const U &container, std::vector< int > indices)
 Get items by indices from a container. More...
 
template<typename U >
MCUniqueItemsFromContainer (const U &container)
 Get unique items from a container. More...
 
template<typename U >
MCCommonValuesFromContainers (const U &first_container, const U &second_container)
 Count common values in two containers. More...
 
template<typename T , typename U >
int MCItemCountInContainer (const U &container, const T item)
 Calculate the number of a given item in a container. More...
 
template<typename T , typename U , typename V >
int MCItemCountInTable (const V &table, const T item)
 Calculate the number of a given item in a table. More...
 
template<typename U >
MCNthItemsFromContainer (const U &container, unsigned int n_th, unsigned int period)
 Get items from n-th indexes of a container. More...
 
template<typename T , typename U >
void MCReplaceItemInContainer (U &container, const T item, const T new_value)
 Replace an item in a container. More...
 
template<typename T , typename U >
std::pair< int, T > MCSearchMinimalValueWithIndex (const U &container)
 Search the minimal value in a container. More...
 
template<typename T , typename U >
std::pair< int, T > MCSearchMaximalValueWithIndex (const U &container)
 Search the maximal value in a container. More...
 
template<typename T , typename U >
MCSearchMinimalValue (const U &container)
 Search the minimal value in a container. More...
 
template<typename T , typename U >
MCSearchMaximalValue (const U &container)
 Search the maximal value in a container. More...
 
template<typename U , typename V >
MCGetTableColumn (const V &table, unsigned int column_index)
 Get a column from a table as a container. More...
 
template<typename U , typename V >
MCGetTableColumns (const V &table, unsigned int start_column, unsigned int column_count)
 Get columns from a table. More...
 
template<typename V >
void MCEraseTableColumns (V &table, unsigned int start_column, unsigned int column_count)
 Erase columns from a table. More...
 
template<typename V >
std::vector< std::vector< float > > MCCalculateMeanStDevForTableColumns (const V &table)
 Calculate standard deviation and arithmetic mean for table columns. More...
 
template<typename U , typename T >
void MCStandardizeVector (U &vector, const std::vector< std::vector< float > > &mean_stdev_table)
 Standardize a vector. More...
 
template<typename T , typename U , typename V >
void MCStandardizeTablePerColumns (V &table, const std::vector< std::vector< float > > &mean_stdev_table)
 Standardize a table per column. More...
 
template<typename V >
std::vector< std::vector< float > > MCCalculateMinMaxForTableColumns (const V &table)
 Calculate minimums and maximums for table columns. More...
 
template<typename U , typename T >
void MCRescaleVectorByMinMax (U &vector, const std::vector< std::vector< float > > &min_max_table)
 Rescale a vector by minimum-maximum. More...
 
template<typename T , typename U , typename V >
void MCRescaleTablePerColumnsByMinMax (V &table, const std::vector< std::vector< float > > &min_max_table)
 Rescale a table per column by minimum-maximum. More...
 
template<typename U , typename T >
void MCRescaleVectorByLength (U &vector)
 Rescale a vector by "row length". More...
 
template<typename T , typename U , typename V >
void MCRescaleTablePerRowByRowLength (V &table)
 Rescale a table per row by "row length". More...
 
template<typename V >
void MCExportTableToTsvFile (const std::string &file_name, const MC::StringList &header, const V &table, bool export_row_index=false)
 Export a table to tabulator separated values (tsv) file. More...
 
template<typename U , typename V >
void MCExportFeatureTableToTsvFile (const std::string &file_name, const V &table, const U &labels, const MC::StringList &feature_names=MC::StringList(), bool export_row_index=false)
 Export a feature table with labels to a tsv (tabulator separated values) file. More...
 
template<typename U , typename V >
void MCExportFeatureTableToArffFile (const std::string &file_name, const V &table, const U &labels, const MC::StringList &feature_names=MC::StringList())
 Export a feature table and labels to an Arff (Weka) file. More...
 
template<typename U >
void MCPrintContainerAsFloats (U &container, const std::string &message="", unsigned int digits=2)
 Print a container to the output as float numbers. More...
 
template<typename U >
void MCPrintContainerAsInts (U &container, const std::string &message="")
 Print a container to the output as integer numbers. More...
 
template<typename V >
void MCPrintTableAsFloats (V &table, const std::string &message="", unsigned int digits=2)
 Print a table to the output as float numbers. More...
 
template<typename V >
void MCPrintTableAsInts (V &table, const std::string &message="")
 Print a table to the output as integer numbers. More...
 
template<typename T >
MCBinaryDataMCEncodeToBinaryData (const T &data, bool portable=true)
 Encode a data into binary form. More...
 
template<typename T >
boost::shared_ptr< T > MCDecodeFromBinaryData (const MCBinaryData &data, bool portable=true)
 Decode a data from binary form. More...
 
template<typename T >
std::string MCEncodeToString (const T &data, bool portable=true)
 Encode a data into a string. More...
 
template<typename T >
boost::shared_ptr< T > MCDecodeFromString (const std::string &data_str, bool portable=true)
 Decode a data from a string. More...
 
template<typename T >
Indexer< T > index (T &t)
 Iterator magic for for loops to get the index while iterating through. More...
 
template<typename T >
MCRandComplex (const T &min, const T &max)
 Get a random number generated with an advanced algorithm. More...
 
template<typename T >
MCRand (const T &min, const T &max)
 Get a random number generated with standard calls. More...
 
int MCRandSign ()
 Generate a random sign. More...
 
void MCSleep (unsigned int msecs)
 Wait for some milliseconds. More...
 
float MCFloatInfinity ()
 Get float infinity. More...
 
double MCDoubleInfinity ()
 Get double infinity. More...
 
bool MCIsFloatInfinity (const float value)
 Check a value for float infinity. More...
 
bool MCIsDoubleInfinity (const double value)
 Check a value for double infinity. More...
 
float MCRound (float number)
 Round a float number. More...
 
float MCScaleValue (float value, float min, float max, float new_max)
 Scale a value to a new range. More...
 
template<typename T >
std::string MCToStr (const T value, bool hex_manipulator=false)
 Convert an other type to string with std::stringstream. More...
 
template<typename T >
MCStrConvert (const std::string &str)
 Convert a string to an other type with std::stringstream. More...
 
template<typename T >
MCAbs (const T &value)
 Calculate absolute value. More...
 
int MCCompare (const std::string &item, const std::string &a, const std::string &b)
 Decide whether a string is relative closer to other strings. More...
 
template<typename T >
int MCCompare (const T &item, const T &a, const T &b)
 Decide whether a value is relative closer to other values. More...
 
int MCCompare (const std::string &a, const std::string &b)
 Case-insensitive comparison of two strings. More...
 
template<typename T >
int MCCompare (const T &a, const T &b)
 Compare two values. More...
 
template<typename T >
const T & MCMin (const T &a, const T &b)
 Get the minimum of two values. More...
 
template<typename T >
const T & MCMax (const T &a, const T &b)
 Get the maximum of two values. More...
 
template<typename T >
const T & MCBound (const T &min, const T &value, const T &max)
 Check a value bound according to a range. More...
 
template<typename T >
bool MCRangeCheck (const T &value, const T &min, const T &max)
 Range check of a value. More...
 
template<typename T >
std::string MCGetClassName (T *instance=nullptr, const std::string &name_suffix="")
 Get a class name. More...
 
bool MCFileExists (const std::string &file_name)
 Check whether a file exists. More...
 
int MCGetFileSize (const std::string &file_name)
 Get file size. More...
 
bool MCCreatePath (const QString &path_str)
 Create a new path if it does not exist. More...
 
bool MCRemoveDirectory (const QString &dir_str)
 Remove a directory with its content. More...
 
QString MCFixPath (const QString &path)
 Fix the (back)slashes in a path according to the platform. More...
 
void MCAddSearchPath (const QString &path)
 Add a location to the search path for data files. More...
 
QString MCGetDataFile (const QString &file_name)
 Search a data file. More...
 
QString MCGetDataSubdirectory (const QString &subdirectory)
 Get a data subdirectory. More...
 

Detailed Description

Enumeration Type Documentation

Timer modes

Enumerator
NoExpiration 

No expiration

SimpleExpiration 

Simple expiration

SingleShot 

Single shot

PeriodicShots 

Periodic shot

Definition at line 45 of file MCTimer.hpp.

Function Documentation

template<typename T >
Indexer<T> index ( T &  t)

Iterator magic for for loops to get the index while iterating through.

Taken from: http://stackoverflow.com/a/10962575/602173

Usage:

for (auto iter: index(container)) cout << "Index: " << iter.i << " - Value: " << *iter;

Definition at line 146 of file MCDefs.hpp.

template<typename T >
T MCAbs ( const T &  value)

Calculate absolute value.

Parameters
valueValue
Returns
Absolute value

Definition at line 399 of file MCDefs.hpp.

void MCAddSearchPath ( const QString &  path)

Add a location to the search path for data files.

Parameters
pathPath

Definition at line 414 of file MCDefs.cpp.

template<typename T , typename V >
void MCAddValueToTable ( V &  table,
value 
)

Add value to table items.

Parameters
tableTable
valueValue

Definition at line 677 of file MCContainers.hpp.

template<typename T , typename U >
std::pair<int, T> MCBinarySearch ( const U &  container,
const T &  value,
bool  nearest = false 
)

Binary search for a value in a container.

Parameters
containerContainer
valueValue to be searched
nearestFallback to nearest value (true - nearest value is satisfactory; false - search for exact value.)
Returns
A pair of found value and its index inside the container otherwise (-1, default value) is returned.

Definition at line 272 of file MCContainers.hpp.

template<typename T , typename U >
std::pair<int, T> MCBinarySearch ( const U &  container,
const T &  value,
int  min_index,
int  max_index,
bool  nearest = false 
)

Binary search for a value in a certain range of a container.

Parameters
containerContainer
valueValue to be searched
min_indexMinimal search index
max_indexMaximal search index
nearestFallback to nearest value (true - nearest value is satisfactory; false - search for exact value.)
Returns
A pair of found value and its index inside the container otherwise (-1, default value) is returned.

Definition at line 293 of file MCContainers.hpp.

template<typename T >
std::pair<int, T> MCBinarySearch ( const std::vector< T > &  container,
const T &  value,
bool  nearest = false 
)

Binary search for a value in a vector.

Parameters
containerVector
valueValue to be searched
nearestFallback to nearest value (true - nearest value is satisfactory; false - search for exact value.)
Returns
A pair of found value and its index inside the vector otherwise (-1, default value) is returned.

Definition at line 380 of file MCContainers.hpp.

template<typename T >
std::pair<int, T> MCBinarySearch ( const std::vector< T > &  container,
const T &  value,
int  min_index,
int  max_index,
bool  nearest = false 
)

Binary search for a value in a certain range of a vector.

Parameters
containerVector
valueValue to be searched
min_indexMinimal search index
max_indexMaximal search index
nearestFallback to nearest value (true - nearest value is satisfactory; false - search for exact value.)
Returns
A pair of found value and its index inside the vector otherwise (-1, default value) is returned.

Definition at line 401 of file MCContainers.hpp.

template<typename T >
const T& MCBound ( const T &  min,
const T &  value,
const T &  max 
)

Check a value bound according to a range.

Parameters
minMinimum of the range
valueValue
maxMaximum of the range
Returns
min if value is lower than min, max if value is greater than max otherwise value.

Definition at line 527 of file MCDefs.hpp.

template<typename V >
std::vector<std::vector<float> > MCCalculateMeanStDevForTableColumns ( const V &  table)

Calculate standard deviation and arithmetic mean for table columns.

Parameters
tableTable
Returns
A two-row float table, first is the arithmetic mean for each column, second is the standard deviation for each column; otherwise empty table.

Definition at line 1334 of file MCContainers.hpp.

template<typename V >
std::vector<std::vector<float> > MCCalculateMinMaxForTableColumns ( const V &  table)

Calculate minimums and maximums for table columns.

Parameters
tableTable
Returns
A two-row float table, first is the minimum for each column, second is the maximum for each column; otherwise empty table.

Definition at line 1440 of file MCContainers.hpp.

template<typename U >
U MCCommonValuesFromContainers ( const U &  first_container,
const U &  second_container 
)

Count common values in two containers.

Parameters
first_containerFirst container
second_containerSecond container
Returns
A new container with common values.

Definition at line 997 of file MCContainers.hpp.

int MCCompare ( const std::string &  item,
const std::string &  a,
const std::string &  b 
)

Decide whether a string is relative closer to other strings.

Parameters
itemItem to be checked
aFirst candidate
bSecond candidate
Returns
-1 if item is closer to a, +1 if item is closer to b otherwise zero (item in the middle between a and b).

The check is case-insensitive.

Definition at line 167 of file MCDefs.cpp.

template<typename T >
int MCCompare ( const T &  item,
const T &  a,
const T &  b 
)

Decide whether a value is relative closer to other values.

Parameters
itemItem to be checked
aFirst candidate
bSecond candidate
Returns
-1 if item is closer to a, +1 if item is closer to b otherwise zero (item in the middle between a and b).

Definition at line 433 of file MCDefs.hpp.

int MCCompare ( const std::string &  a,
const std::string &  b 
)

Case-insensitive comparison of two strings.

Parameters
aFirst string
bSecond string
Returns
+1 if a is lower than b, -1 if a is greater than b otherwise zero (a and b are equal).

Definition at line 198 of file MCDefs.cpp.

template<typename T >
int MCCompare ( const T &  a,
const T &  b 
)

Compare two values.

Parameters
aFirst value
bSecond value
Returns
+1 if a is lower than b, -1 if a is greater than b otherwise zero (a and b are equal).

Definition at line 470 of file MCDefs.hpp.

template<typename T , typename U >
bool MCContainerContains ( const U &  container,
const T &  value 
)

Check if a container contains a value.

Parameters
containerContainer
valueSearched value
Returns
True if the container contains the value otherwise false.

Definition at line 527 of file MCContainers.hpp.

bool MCCreatePath ( const QString &  path_str)

Create a new path if it does not exist.

Parameters
path_strPath string
Returns
True if successful otherwise false.

Definition at line 344 of file MCDefs.cpp.

template<typename T >
boost::shared_ptr<T> MCDecodeFromBinaryData ( const MCBinaryData data,
bool  portable = true 
)

Decode a data from binary form.

Parameters
dataBinary data to be decoded
portableWhether the decoded binary data is portable
Returns
Decoded data shared pointer otherwise empty shared pointer.

The function decodes the data internally from a data container.

Definition at line 350 of file MCDataContainer.hpp.

template<typename T >
boost::shared_ptr<T> MCDecodeFromString ( const std::string &  data_str,
bool  portable = true 
)

Decode a data from a string.

Parameters
data_strString to be decoded
portableWhether the decoded binary data is portable
Returns
Decoded data shared pointer otherwise empty shared pointer.

The function decodes the data internally from a data container.

Definition at line 401 of file MCDataContainer.hpp.

template<typename T , typename U , typename V >
U MCDiagonalItemsFromTable ( const V &  table,
bool  top_left_to_right_bottom = true 
)

Get the diagonal items of a squared table.

Parameters
tableTable
top_left_to_right_bottomTrue or false to indicate the diagonal type
Returns
Items otherwise empty container.

Definition at line 866 of file MCContainers.hpp.

double MCDoubleInfinity ( )

Get double infinity.

Returns
Double infinity

Definition at line 116 of file MCDefs.cpp.

template<typename T >
MCBinaryData* MCEncodeToBinaryData ( const T &  data,
bool  portable = true 
)

Encode a data into binary form.

Parameters
dataData to be encoded
portableWhether the encoded binary data is portable
Returns
Data in binary form otherwise NULL.

The function parses the data internally into a data container and encodes in binary form.

Definition at line 329 of file MCDataContainer.hpp.

template<typename T >
std::string MCEncodeToString ( const T &  data,
bool  portable = true 
)

Encode a data into a string.

Parameters
dataData to be encoded
portableWhether the encoded binary data is portable
Returns
Data encoded into a string otherwise NULL.

The function parses the data internally into a data container and encodes in binary form. Eventually, the binary data is converted to base64.

Definition at line 381 of file MCDataContainer.hpp.

template<typename V >
void MCEraseTableColumns ( V &  table,
unsigned int  start_column,
unsigned int  column_count 
)

Erase columns from a table.

Parameters
tableTable
start_columnStart column
column_countColumn count to be erased

Definition at line 1305 of file MCContainers.hpp.

template<typename U , typename V >
void MCExportFeatureTableToArffFile ( const std::string &  file_name,
const V &  table,
const U &  labels,
const MC::StringList &  feature_names = MC::StringList() 
)

Export a feature table and labels to an Arff (Weka) file.

Parameters
file_nameFile name
tableFeature table
labelsLabels
feature_namesFeature names

Definition at line 1698 of file MCContainers.hpp.

template<typename U , typename V >
void MCExportFeatureTableToTsvFile ( const std::string &  file_name,
const V &  table,
const U &  labels,
const MC::StringList &  feature_names = MC::StringList(),
bool  export_row_index = false 
)

Export a feature table with labels to a tsv (tabulator separated values) file.

Parameters
file_nameFile name
tableFeature table
labelsLabels
feature_namesFeature names
export_row_indexWhether row indexes to be exported

Definition at line 1646 of file MCContainers.hpp.

template<typename V >
void MCExportTableToTsvFile ( const std::string &  file_name,
const MC::StringList &  header,
const V &  table,
bool  export_row_index = false 
)

Export a table to tabulator separated values (tsv) file.

Parameters
file_nameFile name
headerHeader strings
tableTable
export_row_indexWhether row indexes to be exported

Definition at line 1584 of file MCContainers.hpp.

bool MCFileExists ( const std::string &  file_name)

Check whether a file exists.

Parameters
file_nameFile name
Returns
True if the file exists otherwise false.

Definition at line 226 of file MCDefs.cpp.

QString MCFixPath ( const QString &  path)

Fix the (back)slashes in a path according to the platform.

Parameters
pathPath
Returns
New path

Definition at line 399 of file MCDefs.cpp.

float MCFloatInfinity ( )

Get float infinity.

Returns
Float infinity

Definition at line 110 of file MCDefs.cpp.

template<typename T >
std::string MCGetClassName ( T *  instance = nullptr,
const std::string &  name_suffix = "" 
)

Get a class name.

Parameters
instanceObject instance
name_suffixName suffix
Returns
Class name

Definition at line 627 of file MCDefs.hpp.

template<typename T , typename U >
std::vector<T> MCGetContainerKeys ( const U &  container)

Get container keys as a vector.

Parameters
containerContainer
Returns
The vector of container keys.

Definition at line 484 of file MCContainers.hpp.

template<typename T , typename U >
std::vector<T> MCGetContainerValues ( const U &  container)

Get container values as a vector.

Parameters
containerContainer
Returns
The vector of container values.

Definition at line 505 of file MCContainers.hpp.

QString MCGetDataFile ( const QString &  file_name)

Search a data file.

Parameters
file_nameFile name
Returns
Found data file or empty string

This method searches for a file in the current directory and in the locations added by MCAddSearchPath().

Definition at line 425 of file MCDefs.cpp.

QString MCGetDataSubdirectory ( const QString &  subdirectory)

Get a data subdirectory.

Parameters
subdirectorySubdirectory
Returns
Found data subdirectory or empty string

This method searches for a subdirectory in the current directory and in the locations added by MCAddSearchPath().

Definition at line 453 of file MCDefs.cpp.

int MCGetFileSize ( const std::string &  file_name)

Get file size.

Parameters
file_nameFile name
Returns
File size otherwise -1.

Definition at line 239 of file MCDefs.cpp.

template<typename T , typename U >
T MCGetMostFrequentItemFromContainer ( const U &  container)

Get the most frequent item of a container.

Parameters
containerContainer
Returns
Most frequent item or zero for an empty container.

Definition at line 594 of file MCContainers.hpp.

template<typename T , typename U >
QMap<T, U>::const_iterator MCGetQMapConstIteratorByIndex ( const QMap< T, U > &  container,
const int  index 
)

Get the iterator for a certain item from a QMap.

Parameters
containerThe container where the search is done
indexThe desired index of the iterator
Returns
The iterator otherwise container.end()

Definition at line 201 of file MCContainers.hpp.

template<typename T , typename U >
U MCGetQMapItemByIndex ( const QMap< T, U > &  container,
const int  index 
)

Get a certain item from a QMap.

Parameters
containerThe container where the search is done
indexThe desired index
Returns
The item otherwise a default item

Definition at line 179 of file MCContainers.hpp.

template<typename T , typename U >
QMap<T, U>::iterator MCGetQMapIteratorByIndex ( QMap< T, U > &  container,
const int  index 
)

Get the iterator for a certain item from a QMap.

Parameters
containerThe container where the search is done
indexThe desired index of the iterator
Returns
The iterator otherwise container.end()

Definition at line 230 of file MCContainers.hpp.

template<typename T , typename U >
int MCGetQMapKeyIndex ( const QMap< T, U > &  container,
const T &  key 
)

Get the index of a key in a QMap.

Parameters
containerThe container where the search is done
keySearched key
Returns
The index otherwise -1

Definition at line 153 of file MCContainers.hpp.

template<typename U , typename V >
U MCGetTableColumn ( const V &  table,
unsigned int  column_index 
)

Get a column from a table as a container.

Parameters
tableTable
column_indexColumn index
Returns
A new container with the desired column

Definition at line 1242 of file MCContainers.hpp.

template<typename U , typename V >
V MCGetTableColumns ( const V &  table,
unsigned int  start_column,
unsigned int  column_count 
)

Get columns from a table.

Parameters
tableTable
start_columnStart column
column_countColumn count to be copied
Returns
A new table with the requested columns

Definition at line 1273 of file MCContainers.hpp.

template<typename V >
bool MCIsConsistentTable ( V &  table)

Check the consistency of a table.

Parameters
tableTable
Returns
True if the table is not empty and all rows has the same size, otherwise false.

Definition at line 630 of file MCContainers.hpp.

bool MCIsDoubleInfinity ( const double  value)

Check a value for double infinity.

Parameters
valueValue to be checked
Returns
True if the value contains infinity otherwise false

Definition at line 132 of file MCDefs.cpp.

bool MCIsFloatInfinity ( const float  value)

Check a value for float infinity.

Parameters
valueValue to be checked
Returns
True if the value contains infinity otherwise false

Definition at line 122 of file MCDefs.cpp.

template<typename T , typename U >
int MCItemCountInContainer ( const U &  container,
const T  item 
)

Calculate the number of a given item in a container.

Parameters
containerContainer
itemItem to be counted
Returns
The number of the searched item

Definition at line 1028 of file MCContainers.hpp.

template<typename T , typename U , typename V >
int MCItemCountInTable ( const V &  table,
const T  item 
)

Calculate the number of a given item in a table.

Parameters
tableTable
itemItem to be counted
Returns
The number of the searched item

Definition at line 1055 of file MCContainers.hpp.

template<typename T , typename U >
std::vector<int> MCItemIndicesInContainer ( const U &  container,
const T  item 
)

Get item indices in a container.

Parameters
containerContainer
itemItem to be found
Returns
The indices of the searched item otherwise empty list.

Definition at line 912 of file MCContainers.hpp.

template<typename T , typename U >
std::vector<T> MCItemsByIndicesFromContainer ( const U &  container,
std::vector< int >  indices 
)

Get items by indices from a container.

Parameters
containerContainer
indicesIndices
Returns
Item otherwise empty list.

Definition at line 940 of file MCContainers.hpp.

template<typename T , typename U >
const T MCMax ( const U &  container)

Get the maximal value of a container.

Parameters
containerContainer
Returns
Maximal value or zero if the container is empty.

Definition at line 82 of file MCContainers.hpp.

template<typename T >
const T& MCMax ( const T &  a,
const T &  b 
)

Get the maximum of two values.

Parameters
aFirst value
bSecond value
Returns
Maximum of a and b.

Definition at line 507 of file MCDefs.hpp.

template<typename U >
void MCMergeContainers ( U &  target,
const U &  other 
)

Merge two containers.

Parameters
targetTarget container
otherOther container

Definition at line 896 of file MCContainers.hpp.

template<typename T , typename U >
const T MCMin ( const U &  container)

Get the minimal value of a container.

Parameters
containerContainer
Returns
Minimal value or zero if the container is empty.

Definition at line 56 of file MCContainers.hpp.

template<typename T >
const T& MCMin ( const T &  a,
const T &  b 
)

Get the minimum of two values.

Parameters
aFirst value
bSecond value
Returns
Minimum of a and b.

Definition at line 489 of file MCDefs.hpp.

template<typename T , typename U >
void MCMultiplyContainer ( U &  container,
multiplier 
)

Multiple a container by a value.

Parameters
containerContainer
multiplierMultiplier

Definition at line 543 of file MCContainers.hpp.

template<typename T , typename V >
void MCMultiplyTable ( V &  table,
multiplier 
)

Multiply table by value.

Parameters
tableTable
multiplierMultiplier

Definition at line 758 of file MCContainers.hpp.

template<typename T , typename V >
void MCMultiplyTableColumn ( V &  table,
unsigned int  column_index,
multiplier 
)

Multiple table column by a value.

Parameters
tableTable
column_indexColumn index
multiplierMultiplier

Definition at line 730 of file MCContainers.hpp.

template<typename T , typename V >
void MCMultiplyTableRow ( V &  table,
unsigned int  row_index,
multiplier 
)

Multiple table row by a value.

Parameters
tableTable
row_indexRow index
multiplierMultiplier

Definition at line 701 of file MCContainers.hpp.

template<typename U >
U MCNthItemsFromContainer ( const U &  container,
unsigned int  n_th,
unsigned int  period 
)

Get items from n-th indexes of a container.

Parameters
containerContainer
n_thNth items of a period to be extracted
periodPeriod
Returns
Items from n-th indexes otherwise false

The container indexes are incremented by one (index 0 -> 1, 1 -> 2 etc).

Definition at line 1084 of file MCContainers.hpp.

template<typename U >
void MCPrintContainerAsFloats ( U &  container,
const std::string &  message = "",
unsigned int  digits = 2 
)

Print a container to the output as float numbers.

Parameters
containerContainer
messageMessage to be printed before the table
digitsPrinted digits

Definition at line 1770 of file MCContainers.hpp.

template<typename U >
void MCPrintContainerAsInts ( U &  container,
const std::string &  message = "" 
)

Print a container to the output as integer numbers.

Parameters
containerContainer
messageMessage to be printed before the table

Definition at line 1799 of file MCContainers.hpp.

template<typename V >
void MCPrintTableAsFloats ( V &  table,
const std::string &  message = "",
unsigned int  digits = 2 
)

Print a table to the output as float numbers.

Parameters
tableTable
messageMessage to be printed before the table
digitsPrinted digits

Definition at line 1828 of file MCContainers.hpp.

template<typename V >
void MCPrintTableAsInts ( V &  table,
const std::string &  message = "" 
)

Print a table to the output as integer numbers.

Parameters
tableTable
messageMessage to be printed before the table

Definition at line 1866 of file MCContainers.hpp.

MC::StringList MCQStringListToStdStrings ( const QStringList &  string_list)

Convert a QStringList to std::string vector.

Parameters
string_listA QString vector
Returns
New std::string vector

Definition at line 38 of file MCContainers.cpp.

template<typename T >
std::vector<std::vector<T> > MCQVectorTableToStdVectorTable ( const QVector< QVector< T > > &  table)

Convert QVector based table to std::vector based table.

Parameters
tableQVector based table
Returns
std::vector based table

Definition at line 131 of file MCContainers.hpp.

template<typename T >
T MCRand ( const T &  min,
const T &  max 
)

Get a random number generated with standard calls.

Parameters
minMinimum value of the range
maxMaximum value of the range
Returns
Random number between min <= x <= max.

Definition at line 248 of file MCDefs.hpp.

template<typename T >
T MCRandComplex ( const T &  min,
const T &  max 
)

Get a random number generated with an advanced algorithm.

Parameters
minMinimum value of the range
maxMaximum value of the range
Returns
Random number between min <= x <= max.

Definition at line 230 of file MCDefs.hpp.

int MCRandSign ( )

Generate a random sign.

Returns
-1 or +1

Definition at line 79 of file MCDefs.cpp.

template<typename T >
bool MCRangeCheck ( const T &  value,
const T &  min,
const T &  max 
)

Range check of a value.

Parameters
valueValue
minMinimum of the range
maxMaximum of the range
Returns
True if value is inside the range [min, max] otherwise false.

Definition at line 544 of file MCDefs.hpp.

bool MCRemoveDirectory ( const QString &  dir_str)

Remove a directory with its content.

Parameters
dir_strDirectory string
Returns
True if successful otherwise false.

Definition at line 370 of file MCDefs.cpp.

template<typename T , typename U >
void MCReplaceItemInContainer ( U &  container,
const T  item,
const T  new_value 
)

Replace an item in a container.

Parameters
containerContainer
itemItem to be replaced
new_valueNew value for the replaced item

Definition at line 1107 of file MCContainers.hpp.

template<typename T , typename U , typename V >
void MCRescaleTablePerColumnsByMinMax ( V &  table,
const std::vector< std::vector< float > > &  min_max_table 
)

Rescale a table per column by minimum-maximum.

Parameters
tableTable to be normalized
min_max_tableMinimums and maximums table for columns

Definition at line 1510 of file MCContainers.hpp.

template<typename T , typename U , typename V >
void MCRescaleTablePerRowByRowLength ( V &  table)

Rescale a table per row by "row length".

Parameters
tableTable to be normalized

Definition at line 1557 of file MCContainers.hpp.

template<typename U , typename T >
void MCRescaleVectorByLength ( U &  vector)

Rescale a vector by "row length".

Parameters
vectorVector to be normalized

Definition at line 1535 of file MCContainers.hpp.

template<typename U , typename T >
void MCRescaleVectorByMinMax ( U &  vector,
const std::vector< std::vector< float > > &  min_max_table 
)

Rescale a vector by minimum-maximum.

Parameters
vectorVector to be normalized
min_max_tableMinimums and maximums table for each element

Definition at line 1485 of file MCContainers.hpp.

float MCRound ( float  number)

Round a float number.

Parameters
numberNumber to be rounded
Returns
Rounded result

If the fraction is .5 or lower then it rounds down otherwise up.

Definition at line 142 of file MCDefs.cpp.

float MCScaleValue ( float  value,
float  min,
float  max,
float  new_max 
)

Scale a value to a new range.

Parameters
valueValue to be scaled
minMinimum
maxMaximum
new_maxNew maximal value of the range
Returns
Scaled value otherwise infinity

Definition at line 154 of file MCDefs.cpp.

template<typename T , typename U >
T MCSearchMaximalValue ( const U &  container)

Search the maximal value in a container.

Parameters
containerContainer
Returns
Maximal value

Definition at line 1216 of file MCContainers.hpp.

template<typename T , typename U >
std::pair<int, T> MCSearchMaximalValueWithIndex ( const U &  container)

Search the maximal value in a container.

Parameters
containerContainer
Returns
Pair of the found index and the value otherwise (-1; 0)

Definition at line 1161 of file MCContainers.hpp.

template<typename T , typename U >
T MCSearchMinimalValue ( const U &  container)

Search the minimal value in a container.

Parameters
containerContainer
Returns
Minimal value

Definition at line 1191 of file MCContainers.hpp.

template<typename T , typename U >
std::pair<int, T> MCSearchMinimalValueWithIndex ( const U &  container)

Search the minimal value in a container.

Parameters
containerContainer
Returns
Pair of the found index and the value otherwise (-1; 0)

Definition at line 1131 of file MCContainers.hpp.

template<typename T , typename U >
void MCShiftContainerbyValue ( U &  container,
shift_value 
)

Shift container values.

Parameters
containerContainer
shift_valueShift value

Definition at line 657 of file MCContainers.hpp.

void MCSleep ( unsigned int  msecs)

Wait for some milliseconds.

Parameters
msecsMilliseconds

Definition at line 89 of file MCDefs.cpp.

template<typename T , typename U , typename V >
void MCStandardizeTablePerColumns ( V &  table,
const std::vector< std::vector< float > > &  mean_stdev_table 
)

Standardize a table per column.

Parameters
tableTable to be normalized
mean_stdev_tableMean and standard deviation table for columns

Definition at line 1412 of file MCContainers.hpp.

template<typename U , typename T >
void MCStandardizeVector ( U &  vector,
const std::vector< std::vector< float > > &  mean_stdev_table 
)

Standardize a vector.

Parameters
vectorVector to be normalized
mean_stdev_tableMean and standard deviation table for each elements

Definition at line 1387 of file MCContainers.hpp.

QStringList MCStdStringsToQStringList ( const MC::StringList &  string_list)

Convert a std::string vector to QStringList.

Parameters
string_listStd string vector
Returns
New Qt string list

Definition at line 26 of file MCContainers.cpp.

template<typename T >
T MCStrConvert ( const std::string &  str)

Convert a string to an other type with std::stringstream.

Parameters
strString to be converted
Returns
Final string

Definition at line 380 of file MCDefs.hpp.

template<typename T , typename U >
void MCSumContainers ( U &  target_container,
const U &  second_container,
multiplier 
)

Summarize containers.

Parameters
target_containerTarget container
second_containerSecond source container
multiplierMultiplier to apply to the second container elements before summing

Summarizes two containers into a target container. If the target container is empty the second container is just cloned.

Definition at line 564 of file MCContainers.hpp.

template<typename T , typename V >
void MCSumTables ( V &  target_table,
const V &  second_table,
multiplier 
)

Summarize tables.

Parameters
target_tableTarget table
second_tableSecond source table
multiplierMultiplier to apply to the second table elements before summing

Summarizes two tables into the target table. If the target table is empty the second table is just cloned.

Definition at line 785 of file MCContainers.hpp.

template<typename T , typename V >
void MCSwapTableColumns ( V &  table,
unsigned int  column1,
unsigned int  column2 
)

Swap two columns inside a table.

Parameters
tableTable
column1First column to be swapped
column2Second column to be swapped

Definition at line 822 of file MCContainers.hpp.

template<typename T >
std::string MCToStr ( const T  value,
bool  hex_manipulator = false 
)

Convert an other type to string with std::stringstream.

Parameters
valueValue to be converted
hex_manipulatorWhenever the hex manipulator should be used for the conversion
Returns
Final string

Definition at line 360 of file MCDefs.hpp.

template<typename U >
U MCUniqueItemsFromContainer ( const U &  container)

Get unique items from a container.

Parameters
containerContainer
Returns
A new container with unique items.

Definition at line 970 of file MCContainers.hpp.