|
LIPH's C++ Codes
|
Namespaces | |
| namespace | io |
| namespace | noncopyable_ |
| namespace | requests |
Classes | |
| class | avl |
| struct | base64 |
| class | big_integer |
| class | blocking_queue |
| class | csv |
| class | double_buffer |
| class | double_buffer_with_shared_ptr |
| class | final_action |
| class | flags |
| class | hierarchical_mutex |
| class | json |
| class | log_message |
| class | logger |
| class | no_destructor |
| class | prepared_statement |
| class | prime_sieve |
| class | rand |
| struct | random |
| struct | rgb |
| class | scoped_thread |
| struct | singleton |
| class | skip_list |
| class | spinlock |
| class | sqlite |
| class | thread_guard |
| class | threadpool |
| class | timer |
| class | unique_unlock |
Concepts | |
| concept | Printable |
Typedefs | |
| using | file_ptr = std::unique_ptr< FILE, decltype([](FILE *f) { if(f) fclose(f) |
| typedef noncopyable_::noncopyable | noncopyable |
Enumerations | |
| enum class | color256 : uint8_t { Black = 0 , Maroon = 1 , Green = 2 , Olive = 3 , Navy = 4 , Purple = 5 , Teal = 6 , Silver = 7 , Grey = 8 , Red = 9 , Lime = 10 , Yellow = 11 , Blue = 12 , Fuchsia = 13 , Aqua = 14 , White = 15 , NavyBlue = 17 , DarkBlue = 18 , DarkGreen = 22 , DarkCyan = 36 , LightSeaGreen = 37 , DarkTurquoise = 44 , MediumSpringGreen = 49 , DarkRed = 52 , BlueViolet = 57 , SteelBlue = 67 , CornflowerBlue = 69 , CadetBlue = 72 , MediumTurquoise = 80 , DarkMagenta = 90 , DarkViolet = 92 , LightSlateGrey = 103 , MediumPurple = 104 , LightSlateBlue = 105 , DarkSeaGreen = 108 , LightGreen = 119 , MediumVioletRed = 126 , IndianRed = 131 , MediumOrchid = 134 , DarkGoldenrod = 136 , RosyBrown = 138 , DarkKhaki = 143 , LightSteelBlue = 147 , GreenYellow = 154 , Orchid = 170 , Violet = 177 , Tan = 180 , HotPink = 205 , DarkOrange = 208 , LightCoral = 210 , SandyBrown = 215 } |
Functions | |
| template<class T > | |
| void | erase (std::vector< T > &v, const std::set< size_t > &idx) |
| Erases the specified elements from v, according to index in idx. More... | |
| template<class T > | |
| std::vector< T > | topk (const std::vector< T > &data, size_t k) |
| template<class T > | |
| T | find_kth (const std::vector< T > &data, size_t k) |
| template<class T > | |
| int | binary_search (T a[], int n, T val) |
| void | sleeps (int n) |
| void | sleepms (int n) |
| std::string | MD5 (const std::string &msg) |
| std::string | md5 (const std::string &msg) |
| bool | read_file (const std::filesystem::path &pathname, std::string &output) |
| read all from pathname, append to output More... | |
| bool | write_file (const std::filesystem::path &pathname, const std::string &str) |
| write all to pathname More... | |
| bool | path_exists (const std::string &pathname) |
| check path(file or directory) exists More... | |
| std::vector< std::string > | list_files (const std::string &pathname) |
| list all files(including directories) in pathname recursively and sort by names More... | |
| file_ptr | fopen (const char *filename, char const *mode) |
| bool | mkdir (const std::filesystem::path &path) |
| bool | mkdirp (const std::filesystem::path &path) |
| unsigned | bkdr_hash (const char *str) |
| uint64_t | bkdr_hash64 (const char *str) |
| template<typename To , typename From > | |
| To | implicit_cast (const From &f) |
| template<typename To , typename From > | |
| To | down_cast (From *f) |
| template<typename To , typename From > | |
| To | down_cast (From &f) |
| template<typename To , typename From > | |
| To | bit_cast (const From &from) |
| template<class T > | |
| std::string | demangle () |
| template<class T > | |
| std::string | demangle (const T &t) |
| template<class F > | |
| auto | finally (F &&f) noexcept |
| template<class T > | |
| T | make_default () |
| template<class T1 , class T2 > | |
| std::ostream & | operator<< (std::ostream &o, const std::pair< T1, T2 > &p) |
| std::ostream & | operator<< (std::ostream &o, const std::vector< bool > &vb) |
| std::ostream & | operator<< (std::ostream &o, const char *s) |
| std::ostream & | operator<< (std::ostream &o, const std::string &s) |
| std::ostream & | operator<< (std::ostream &o, std::string_view s) |
| template<std::ranges::input_range Range> | |
| std::ostream & | operator<< (std::ostream &o, const Range &range) |
| template<class K , class V > | |
| std::ostream & | operator<< (std::ostream &o, const std::map< K, V > &map) |
| template<class K , class V > | |
| std::ostream & | operator<< (std::ostream &o, const std::unordered_map< K, V > &map) |
| void | println () |
| void | print (bool b) |
| template<Printable T> | |
| void | print (T &&t) |
| template<Printable T, Printable... Args> | |
| void | print (T &&head, Args &&...args) |
| template<Printable... Args> | |
| void | print (bool head, Args &&...args) |
| void | err_exit (const char *str=nullptr) |
| void | err_exit (const std::string &str) |
| void | err_exit_if (bool error) |
| void | bzero (void *p, size_t n) |
| int | become_daemon (int flags) |
| bool | single_proc (const char *lock_file_path, bool exit) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | bubble_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | selection_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| RandomIt | partition (RandomIt first, RandomIt last, const Compare &comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | quick_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | merge (RandomIt first, RandomIt mid, RandomIt last, Compare comp=Compare()) |
| 将有序的[first, mid) 和 [mid, last) 合并为有序的 [first, last) More... | |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | merge_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | insert_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| template<class RandomIt , class Distance , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | shell_insert (RandomIt first, RandomIt last, Distance dk, Compare comp=Compare()) |
| template<class RandomIt , class Compare = std::less<typename std::iterator_traits<RandomIt>::value_type>> | |
| void | shell_sort (RandomIt first, RandomIt last, Compare comp=Compare()) |
| void | counting_sort (int A[], int n, int max) |
| void | radix_sort (int A[], int n, int d) |
| void | bucket_sort (int A[], int n, int min, int max, int m) |
| std::string_view | ltrim (std::string_view s, std::string_view charset) |
| std::string_view | rtrim (std::string_view s, std::string_view charset) |
| std::string_view | trim (std::string_view s, std::string_view charset) |
| void | split (std::vector< std::string > &tokens, const std::string &s, const std::string &delimiters=" ") |
| Split @s to tokens by @delimiters and append to @tokens. More... | |
| std::vector< std::string > | split (const std::string &s, const std::string &delimiters=" ") |
| Split @s to tokens by @delimiters and return. More... | |
| std::string | basename (std::string_view path) |
| Return basename of @path. More... | |
| std::string | dirname (std::string_view path) |
| Return dirname of @path. More... | |
| void | skip_whitespace (std::string_view &sv) |
| @sv skips leading whitespace characters and be the substr More... | |
| bool | eat_symbol (std::string_view &sv, std::string_view symbol) |
| std::optional< int > | to_int (std::string_view str) |
| Convert @str to int. More... | |
| std::string | replace (std::string_view str, std::string_view old, std::string_view New) |
| Replace all @old in @str with @New. More... | |
| constexpr bool | startswith (std::string_view s, std::string_view t) noexcept |
| constexpr bool | endswith (std::string_view s, std::string_view t) noexcept |
| template<typename Target = std::string, typename Source = std::string> | |
| Target | to (const Source &s) |
| Convert source to target. More... | |
| template<std::ranges::input_range Range> | |
| std::string | join (const Range &range, const std::string &sep=" ") |
| Join all items in @range into a string, using @sep as separator. More... | |
| std::string | color256fg (unsigned char n) |
| std::string | color256bg (unsigned char n) |
| std::string | color_reset () |
| bool | stdin_echo_on () |
| bool | stdin_echo_off () |
| bool | stdin_buffering_on () |
| bool | stdin_buffering_off () |
| void | clear_screen () |
| void | clear_scrollback_buffer () |
| void | reset_screen () |
| std::string | color256fg (uint8_t) |
| std::string | color256bg (uint8_t) |
| std::string | color256fg (color256 c) |
| std::string | color256bg (color256 c) |
| std::string | text_bold () |
| std::string | text_faint () |
| std::string | text_italic () |
| std::string | text_underline () |
| std::string | text_blink () |
| std::string | text_rapid_blink () |
| std::string | text_reverse () |
| std::string | text_conceal () |
| std::string | text_strikethrough () |
| int | julianday (int year, int month, int day) |
| int | day_of_the_week (int y, int m, int d) |
| using liph::file_ptr = typedef std::unique_ptr<FILE, decltype([](FILE *f) { if (f) fclose(f) |
|
strong |
| std::string liph::basename | ( | std::string_view | path | ) |
Return basename of @path.
| int liph::become_daemon | ( | int | flags | ) |
| int liph::binary_search | ( | T | a[], |
| int | n, | ||
| T | val | ||
| ) |
|
inline |
|
inline |
|
inline |
| void liph::bubble_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
| void liph::bucket_sort | ( | int | A[], |
| int | n, | ||
| int | min, | ||
| int | max, | ||
| int | m | ||
| ) |
|
inline |
| void liph::clear_screen | ( | ) |
| void liph::clear_scrollback_buffer | ( | ) |
|
inline |
| std::string liph::color256bg | ( | uint8_t | ) |
| std::string liph::color256bg | ( | unsigned char | n | ) |
|
inline |
| std::string liph::color256fg | ( | uint8_t | ) |
| std::string liph::color256fg | ( | unsigned char | n | ) |
| std::string liph::color_reset | ( | ) |
| void liph::counting_sort | ( | int | A[], |
| int | n, | ||
| int | max | ||
| ) |
|
inline |
| std::string liph::demangle | ( | ) |
| std::string liph::demangle | ( | const T & | t | ) |
| std::string liph::dirname | ( | std::string_view | path | ) |
Return dirname of @path.
|
inline |
|
inline |
| bool liph::eat_symbol | ( | std::string_view & | sv, |
| std::string_view | symbol | ||
| ) |
@sv skips leading @symbol and be the substr
|
constexprnoexcept |
| void liph::erase | ( | std::vector< T > & | v, |
| const std::set< size_t > & | idx | ||
| ) |
Erases the specified elements from v, according to index in idx.
|
inline |
|
inline |
|
inline |
| T liph::find_kth | ( | const std::vector< T > & | data, |
| size_t | k | ||
| ) |
|
inline |
|
inline |
| void liph::insert_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
| std::string liph::join | ( | const Range & | range, |
| const std::string & | sep = " " |
||
| ) |
Join all items in @range into a string, using @sep as separator.
|
inline |
| std::vector< std::string > liph::list_files | ( | const std::string & | pathname | ) |
list all files(including directories) in pathname recursively and sort by names
| std::string_view liph::ltrim | ( | std::string_view | s, |
| std::string_view | charset = " \n\r\t\f\v" |
||
| ) |
Remove whitespace characters to the left of s
| charset | default: whitespace(" \n\r\t\f\v") |
| T liph::make_default | ( | ) |
| std::string liph::MD5 | ( | const std::string & | msg | ) |
| std::string liph::md5 | ( | const std::string & | msg | ) |
| void liph::merge | ( | RandomIt | first, |
| RandomIt | mid, | ||
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
将有序的[first, mid) 和 [mid, last) 合并为有序的 [first, last)
| void liph::merge_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
|
inline |
mkdir
|
inline |
mkdir -p
|
inline |
| std::ostream & liph::operator<< | ( | std::ostream & | o, |
| const Range & | range | ||
| ) |
| std::ostream & liph::operator<< | ( | std::ostream & | o, |
| const std::map< K, V > & | map | ||
| ) |
| std::ostream & liph::operator<< | ( | std::ostream & | o, |
| const std::pair< T1, T2 > & | p | ||
| ) |
|
inline |
| std::ostream & liph::operator<< | ( | std::ostream & | o, |
| const std::unordered_map< K, V > & | map | ||
| ) |
|
inline |
|
inline |
| RandomIt liph::partition | ( | RandomIt | first, |
| RandomIt | last, | ||
| const Compare & | comp = Compare() |
||
| ) |
| bool liph::path_exists | ( | const std::string & | pathname | ) |
check path(file or directory) exists
|
inline |
| void liph::print | ( | bool | head, |
| Args &&... | args | ||
| ) |
| void liph::print | ( | T && | head, |
| Args &&... | args | ||
| ) |
| void liph::print | ( | T && | t | ) |
|
inline |
| void liph::quick_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
| void liph::radix_sort | ( | int | A[], |
| int | n, | ||
| int | d | ||
| ) |
| bool liph::read_file | ( | const std::filesystem::path & | pathname, |
| std::string & | output | ||
| ) |
read all from pathname, append to output
| std::string liph::replace | ( | std::string_view | str, |
| std::string_view | s, | ||
| std::string_view | t | ||
| ) |
Replace all @old in @str with @New.
| void liph::reset_screen | ( | ) |
| std::string_view liph::rtrim | ( | std::string_view | s, |
| std::string_view | charset = " \n\r\t\f\v" |
||
| ) |
Remove whitespace characters to the right of s
| void liph::selection_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
| void liph::shell_insert | ( | RandomIt | first, |
| RandomIt | last, | ||
| Distance | dk, | ||
| Compare | comp = Compare() |
||
| ) |
增量为 dk 的插入排序 dk = 1 => insert_sort
| void liph::shell_sort | ( | RandomIt | first, |
| RandomIt | last, | ||
| Compare | comp = Compare() |
||
| ) |
| bool liph::single_proc | ( | const char * | lock_file_path, |
| bool | exit | ||
| ) |
| void liph::skip_whitespace | ( | std::string_view & | sv | ) |
@sv skips leading whitespace characters and be the substr
|
inline |
|
inline |
| std::vector< std::string > liph::split | ( | const std::string & | s, |
| const std::string & | delimiters | ||
| ) |
Split @s to tokens by @delimiters and return.
| void liph::split | ( | std::vector< std::string > & | tokens, |
| const std::string & | s, | ||
| const std::string & | delimiters | ||
| ) |
Split @s to tokens by @delimiters and append to @tokens.
|
constexprnoexcept |
| bool liph::stdin_buffering_off | ( | ) |
| bool liph::stdin_buffering_on | ( | ) |
| bool liph::stdin_echo_off | ( | ) |
| bool liph::stdin_echo_on | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| Target liph::to | ( | const Source & | s | ) |
Convert source to target.
| std::optional< int > liph::to_int | ( | std::string_view | s | ) |
Convert @str to int.
| std::vector< T > liph::topk | ( | const std::vector< T > & | data, |
| size_t | k | ||
| ) |
| std::string_view liph::trim | ( | std::string_view | s, |
| std::string_view | charset = " \n\r\t\f\v" |
||
| ) |
Remove whitespace characters to the left and right of s
| bool liph::write_file | ( | const std::filesystem::path & | pathname, |
| const std::string & | str | ||
| ) |
write all to pathname