#include <string>
#include <vector>
#include <array>
#include <complex>
#include <algorithm>
#include <unordered_map>
#include <boost/functional/hash.hpp>
Go to the source code of this file.
|
|
#define | LOG_TRACE_MSG(m) Log::msg(string("") + __FILE__ + ": " + to_string(__LINE__) + ": " + (m)) |
| |
|
#define | LOG_TRACE_FILE "/tmp/milo.log" |
| |
|
#define | LOG_TRACE_CLEAR() remove(LOG_TRACE_FILE) |
| |
|
#define | QUOTE(arg) #arg |
| |
|
#define | STR(macro) QUOTE(macro) |
| |
|
#define | INSTALL_PATH /usr/local/milo |
| |
|
#define | INSTALL_PATH_STR STR(INSTALL_PATH) |
| |
|
|
|
using | Box = Rectangle< int > |
| | Specialization of integer rectangle.
|
| |
|
using | StringMap = std::unordered_map< std::string, std::string > |
| | hash map for string => string
|
| |
|
| template<class T > |
| std::size_t | hash_calculate (std::initializer_list< T > l) |
| |
| void | Log::msg (const std::string &m) |
| |
|
| bool | isZero (double x) |
| |
| bool | isZero (std::complex< double > z) |
| |
| bool | isInteger (const std::string &n) |
| |
| bool | isInteger (double value) |
| |
| std::string | to_hexstring (unsigned long x) |
| |
| template<class T > |
| auto | find (const std::vector< T > &v, const T &val) -> decltype(v.cbegin()) |
| |
| template<class T > |
| void | freeVector (std::vector< T * > &v) |
| |
| template<class T > |
| void | mergeVectors (std::vector< T > &a, std::vector< T > &b) |
| |
| template<class T > |
| void | eraseElement (std::vector< T > &v, int index) |
| |
| template<class T > |
| void | insertElement (std::vector< T > &v, int index, const T &e) |
| |
| template<class T > |
| auto | AddAfter (std::vector< T > &v, decltype(v.begin()) it, const T &elem) -> decltype(v.begin()) |
| |
| template<typename K , typename V > |
| const K | searchMapValue (const std::unordered_map< K, V > &kv_map, V value) |
| |
This file contains miscellaneous functions and declerations.
template<class T >
| auto AddAfter |
( |
std::vector< T > & |
v, |
|
|
decltype(v.begin()) |
it, |
|
|
const T & |
elem |
|
) |
| -> decltype(v.begin())
|
Insert an elememnt after the element pointed to by the given iterator.
- Parameters
-
| v | Vector storing type T. |
| it | Iterator pointing to insert position. |
| e | Element of type T. |
- Returns
- Iterator to inserted element.
template<class T >
| void eraseElement |
( |
std::vector< T > & |
v, |
|
|
int |
index |
|
) |
| |
|
inline |
Erase an element in a vector by index. Helper function to convert index to iterator to erase element.
- Parameters
-
| v | Vector storing type T. |
| index | Index of element to be erased. |
template<class T >
| auto find |
( |
const std::vector< T > & |
v, |
|
|
const T & |
val |
|
) |
| -> decltype( v.cbegin() )
|
|
inline |
Find an iterator to a value in a vector. Template function will look for a value whose type is stored in the given vector. Returns an iterator to the found value or the end iterator if not found.
- Parameters
-
| v | Vector containing type T. |
| val | Value of type T. |
- Returns
- Return iterator to found value or end iterator.
template<class T >
| void freeVector |
( |
std::vector< T * > & |
v | ) |
|
|
inline |
Delete all items in a vector that contains pointers Template function delete each pointer in a vector.
- Parameters
-
| v | Vector containing pointer type T*. |
template<class T >
| std::size_t hash_calculate |
( |
std::initializer_list< T > |
l | ) |
|
|
inline |
Calculate final hash from given list of values
template<class T >
| void insertElement |
( |
std::vector< T > & |
v, |
|
|
int |
index, |
|
|
const T & |
e |
|
) |
| |
|
inline |
Insert an element before the element pointed to by index in vector. Use vector.insert() with iterator created from index.
- Parameters
-
| v | Vector storing type T. |
| index | Index of element where new element will be inserted. |
| e | Element of type T. |
| bool isInteger |
( |
const std::string & |
n | ) |
|
Check if string contains integer value.
- Returns
- True, if integer.
| bool isInteger |
( |
double |
value | ) |
|
Check if double is integer value.
- Returns
- True is fractional value is smaller than a limit.
Check if floating point is smaller than a limit.
- Returns
- If smaller than limit, return true for zero.
| bool isZero |
( |
std::complex< double > |
z | ) |
|
Check if complex floating point is smaller than a limit.
- Returns
- If smaller than limit, return true for zero.
template<class T >
| void mergeVectors |
( |
std::vector< T > & |
a, |
|
|
std::vector< T > & |
b |
|
) |
| |
|
inline |
Merge vector two vectors.
- Parameters
-
| a | Vector ending up items of both vectors. |
| b | Vector whose items are merged and cleared. |
template<typename K , typename V >
| const K searchMapValue |
( |
const std::unordered_map< K, V > & |
kv_map, |
|
|
V |
value |
|
) |
| |
Search for a value in map.
- Parameters
-
| kv_map | Map to be searched. |
| value | Value to look for return Key associated with value. |
| std::string to_hexstring |
( |
unsigned long |
x | ) |
|
|
inline |
Convert long integer to hex string no leading zeroes.
- Returns
- String containing converted hexidecimal string.