6 #ifndef UTILS_EXT_STD_H 7 #define UTILS_EXT_STD_H 11 #include <unordered_set> 13 #include <unordered_map> 36 const std::string WHITESPACES =
" \t\n\r\f\v";
39 inline void StringTo(
const std::string &str,
float &out)
43 inline void StringTo(
const std::string &str,
double &out)
47 inline void StringTo(
const std::string &str, int32_t &out)
51 inline void StringTo(
const std::string &str, int64_t &out)
55 inline void StringTo(
const std::string &str, uint32_t &out)
57 out =
static_cast<unsigned>(std::stoul(str));
59 inline void StringTo(
const std::string &str, uint64_t &out)
61 out = std::stoul(str);
68 inline std::wstring
ToWString(
const std::string &text)
70 return std::wstring(text.begin(), text.end());
76 return std::string(text.begin(), text.end());
80 inline size_t CountOccurrences(
const std::string &text,
const std::string &key_to_search)
83 for (
size_t found_at_pos = 0; ; found_at_pos += key_to_search.length())
85 found_at_pos = text.find(key_to_search, found_at_pos);
86 if (found_at_pos == std::string::npos)
96 inline size_t CountOccurrences(
const std::string &text,
const std::string &key_to_search,
const size_t &off,
const size_t &length)
98 if (length < key_to_search.length())
103 auto last_pos = off + length - key_to_search.length();
104 for (
size_t found_at_pos = off; ; found_at_pos += key_to_search.length())
106 found_at_pos = text.find(key_to_search, found_at_pos);
107 if (found_at_pos == std::string::npos || found_at_pos >= last_pos)
117 inline std::string
Replace(
const std::string &text,
const std::string &key_to_search,
const std::string &replace_text)
119 std::string result = text;
120 for (
size_t found_at_pos = 0; ; found_at_pos += replace_text.length())
122 found_at_pos = result.find(key_to_search, found_at_pos);
123 if (found_at_pos == std::string::npos)
127 result.replace(found_at_pos, key_to_search.length(), replace_text);
136 inline std::string
Replace(
const std::string &text,
const std::map<std::string, std::string> &replacement_map)
138 std::string result = text;
139 for (
const auto &mapped : replacement_map)
141 result =
Replace(result, mapped.first, mapped.second);
147 template <
typename T>
148 inline void Replace(std::vector<T> &vector,
const T old_elem,
const T new_elem)
150 for (
unsigned int i = 0; i < vector.size(); i++)
152 if (vector[i] == old_elem)
154 vector[i] = new_elem;
162 return value ?
"true" :
"false";
175 unsigned uvalue =
static_cast<unsigned>(std::round(std::abs(value * std::pow(10, max_digits))));
176 while (uvalue % 10 == 0)
185 while (uvalue > 0 && max_digits > 0)
187 result += (
'0' + uvalue % 10);
192 while (max_digits-- > 0)
197 std::reverse(result.begin(), result.end());
200 result = std::to_string(static_cast<int>(value));
202 else if (static_cast<int>(value) != 0)
204 result = std::to_string(static_cast<int>(value)) +
"." + result;
208 result = value > 0.0 ?
"0." + result :
"-0." + result;
214 template <
typename T>
217 std::ostringstream out;
218 out << std::setprecision(n) << value;
223 template <
typename T>
226 std::stringstream ss;
227 ss << std::setw(n) << std::setfill(
'0') << value;
232 template <
typename T>
233 inline std::string
ToString(
const std::vector<T> &container,
const std::string &separator =
", ")
236 for (
auto i = 0; i < container.size(); i++)
238 result += std::to_string(container[i]);
239 if (i < container.size() - 1)
248 inline std::string
ToString(
const std::vector<std::string> &container,
const std::string &separator =
", ")
251 for (
size_t i = 0; i < container.size(); i++)
253 result += container[i];
254 if (i < container.size() - 1)
272 std::stringstream temp_stream;
273 temp_stream.imbue(std::locale(
""));
274 temp_stream << input;
275 return temp_stream.str();
281 std::transform(text, text + strlen(text), text, [](
char c) {
return static_cast<char>(::toupper(c)); });
293 std::string upper = text;
294 std::transform(upper.begin(), upper.end(), upper.begin(), ::toupper);
301 std::transform(text, text + strlen(text), text, [](
char c) {
return static_cast<char>(::towlower(c)); });
313 std::string lower = text;
314 std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
319 inline bool EndsWith(
const std::string &ending,
const std::string &text)
322 ending.size() <= text.size() &&
323 std::equal(ending.rbegin(), ending.rend(), text.rbegin());
327 inline bool Contains(
const std::string &substring,
const std::string &text)
329 return text.find(substring) != std::string::npos;
333 inline bool Contains(
const char character,
const std::string &text)
335 return text.find(character) != std::string::npos;
344 const auto regex = std::regex(
"(" + pattern +
")+");
346 const auto it_begin = std::sregex_iterator(base_string.begin(), base_string.end(), regex);
347 const auto it_end = std::sregex_iterator();
349 auto res_string = base_string;
350 for (std::sregex_iterator i = it_begin; i != it_end; ++i)
352 const std::string match_str = i->str();
353 res_string = std::regex_replace(res_string, std::regex(match_str),
ToStringWithZeroes(number, static_cast<int>(match_str.length())), std::regex_constants::format_first_only);
360 template <
typename T>
361 bool Contains(
const T &element,
const std::initializer_list<T> &list)
363 return std::find(list.begin(), list.end(), element) != list.end();
367 template <
typename Type>
368 bool Contains(
const Type &element,
const std::vector<Type> &vector)
370 return std::find(vector.begin(), vector.end(), element) != vector.end();
374 template <
typename Type>
375 std::optional<size_t>
GetIndex(
const Type element,
const std::vector<Type> &vector)
377 const auto found_element = std::find(vector.begin(), vector.end(), element);
378 if (found_element == vector.end())
382 return found_element - vector.begin();
386 template <
typename Type>
387 bool Contains(
const Type element,
const std::set<Type> &
set)
389 return !
set.empty() &&
set.find(element) !=
set.end();
393 template <
typename T1,
typename T2>
394 bool Contains(
const T1 element,
const std::unordered_set<T1, T2> &
set)
396 return set.find(element) !=
set.end();
400 template <
typename T1,
typename T2>
401 bool Contains(
const T1 element,
const std::map<T1, T2> &map)
403 return map.find(element) != map.end();
407 template <
typename T1,
typename T2>
408 bool Contains(
const T1 element,
const std::unordered_map<T1, T2> &map)
410 return map.find(element) != map.end();
414 template <
typename Type>
417 return AnyOf(elements1, [&elements2](
const auto & el) {
return elements2.find(el) != elements2.end(); });
421 template <
typename Type>
424 std::sort(vec.begin(), vec.end());
425 vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
429 template <
typename Type>
432 std::vector<Type> res;
433 res.reserve(vector.size());
434 for (
unsigned i = 0; i < vector.size(); i++)
438 res.push_back(vector[i]);
445 template <
typename Type>
446 bool Erase(
const Type &element, std::vector<Type> &vector)
448 const std::optional<size_t> loc =
GetIndex(element, vector);
451 vector.erase(vector.begin() + loc.value());
453 return loc.has_value();
457 template <
typename Type>
458 bool Erase(
const Type &element, std::set<Type> &
set)
469 template <
typename IndicesType,
typename Type>
470 std::vector<IndicesType>
CollectIndices(
const std::vector<Type> &vector,
const Type value)
472 std::vector<IndicesType> indices;
473 for (IndicesType i = 0; i < static_cast<IndicesType>(vector.size()); ++i)
475 if (vector[i] == value)
477 indices.emplace_back(i);
484 template <
typename T,
typename F>
485 inline void Foreach(
const T &container,
const F &Function)
487 std::for_each(container.begin(), container.end(), Function);
491 template <
typename T>
493 inline auto MaxIt(
const std::vector<T> &vector)
495 return std::max_element(vector.begin(), vector.end());
499 template <
typename T>
501 inline auto MinIt(
const std::vector<T> &vector)
503 return std::min_element(vector.begin(), vector.end());
507 template <
typename T>
509 inline T
Max(
const std::vector<T> &vector)
511 return *
MaxIt(vector);
515 template <
typename T>
517 inline T
Min(
const std::vector<T> &vector)
519 return *
MinIt(vector);
523 template <
typename T>
531 template <
typename T,
typename ... TS>
533 T
Max(
const T val1,
const T val2,
const TS ... vals)
535 return Max(val1 > val2 ? val1 : val2, vals...);
539 template <
typename T>
547 template <
typename T,
typename... TS>
549 inline T
Min(
const T val1,
const T val2,
const TS ... vals)
551 return Min(val1 < val2 ? val1 : val2, vals ...);
555 template <
typename T,
typename F>
557 inline auto Max(
const std::vector<T> &vector,
const F &Function)
559 return *std::max_element(vector.begin(), vector.end(), [&](T
const & lhs, T
const & rhs) {
return Function(lhs) < Function(rhs); });
563 template <
typename T,
typename F>
565 inline auto Min(
const std::vector<T> &vector,
const F &Function)
567 return *std::min_element(vector.begin(), vector.end(), [&](T
const & lhs, T
const & rhs) {
return Function(lhs) < Function(rhs); });
571 template <
typename T,
typename F>
573 inline auto MaxValue(
const std::vector<T> &vector,
const F &Function)
575 return Function(
Max(vector, Function));
579 template <
typename T,
typename F>
581 inline auto MinValue(
const std::vector<T> &vector,
const F &Function)
583 return Function(
Min(vector, Function));
587 template <
typename T,
typename F>
589 inline auto MiddleValue(
const std::vector<T> &vector,
const F &Function)
591 const auto min_value =
MinValue(vector, Function);
592 const auto max_value =
MaxValue(vector, Function);
593 return (min_value + max_value) / 2.0f;
597 template <
typename T>
599 inline auto Accumulate(
const std::vector<T> &vector,
const T start_value)
601 return std::accumulate(vector.begin(), vector.end(), start_value);
605 template <
typename T>
607 inline auto Sum(
const std::vector<T> &vector)
613 template <
typename T>
615 inline auto Average(
const std::vector<T> &vector)
617 return vector.empty()
619 :
Sum(vector) * (1.0f / vector.size());
629 template <
typename T,
typename F>
631 inline auto Accumulate(
const std::vector<T> &vector,
const T initial_value,
const F &
function)
633 return std::accumulate(vector.begin(), vector.end(), initial_value, [&
function](
const T total,
const T value)->T {
return function(value) + total; });
637 template <
typename T,
typename F>
639 inline auto Sum(
const std::vector<T> &vector,
const F &
function)
641 return Accumulate(vector, static_cast<T>(0),
function);
645 template <
typename T,
typename F>
647 inline float Average(
const std::vector<T> &vector,
const F &
function)
649 return vector.empty()
651 :
Sum(vector,
function) /
static_cast<float>(vector.size());
655 template <
typename T>
657 inline auto Median(
const std::vector<T> &vector)
661 return static_cast<T
>(0);
665 const size_t n = vec.size() / 2;
666 std::nth_element(vec.begin(), vec.begin() + n, vec.end());
672 template <
typename T,
typename S>
675 target.insert(target.end(), source.begin(), source.end());
679 template <
typename T,
typename S>
682 target.insert(target.begin(), source.begin(), source.end());
686 template <
typename T,
typename S>
689 target.insert(source.begin(), source.end());
694 template <
typename Type>
699 vector.emplace_back(element);
705 inline std::string &
TrimBegin(std::string &s,
const std::string &t = WHITESPACES)
707 s.erase(0, s.find_first_not_of(t));
712 inline std::string &
TrimEnd(std::string &s,
const std::string &t = WHITESPACES)
714 s.erase(s.find_last_not_of(t) + 1);
719 inline std::string &
Trim(std::string &s,
const std::string &t = WHITESPACES)
735 inline std::vector<std::string>
Parse(
const std::string &text,
const std::string &separators = WHITESPACES)
737 std::vector<std::string> result;
738 result.reserve(text.length());
739 size_t last_end_pos = 0;
742 auto start_pos = text.find_first_not_of(separators, last_end_pos);
743 if (start_pos == std::string::npos)
747 last_end_pos = text.find_first_of(separators, start_pos);
748 auto length = last_end_pos - start_pos;
749 result.emplace_back(text.substr(start_pos, length));
751 result.shrink_to_fit();
758 template <
typename T>
759 inline void Read(T &val, std::istream &str)
761 str.read(reinterpret_cast<char *>(&val),
sizeof(T));
765 template <
typename T>
766 inline T
Read(std::istream &str)
769 str.read(reinterpret_cast<char *>(&val),
sizeof(T));
774 template <
typename T>
775 inline void Write(
const T val, std::ostream &str)
777 str.write(reinterpret_cast<const char *>(&val),
sizeof(T));
780 inline void Read(std::string &, std::istream &)
782 throw std::invalid_argument(
"Function std_ext::Read() cannot be used for reading strings. Use std_ext::ReadString() instead.");
785 inline void Write(
const std::string &, std::ostream &)
787 throw std::invalid_argument(
"Function std_ext::Write() cannot be used for writing strings. Use std_ext::WriteString() instead.");
793 unsigned int len = 0u;
794 str.read((
char *)&len,
sizeof(
unsigned int));
795 char *temp =
new char[len + 1];
811 inline void WriteString(
const std::string &text, std::ostream &str)
813 auto len = unsigned(text.size());
814 str.write((
char *)&len,
sizeof(
unsigned));
815 str.write(text.c_str(), text.size());
821 template<
class C,
class T>
823 auto Find(C &container,
const T &value)
825 return std::find(container.begin(), container.end(), value);
829 template<
class C,
class F>
833 std::vector<decltype(Function(std::declval<typename C::value_type>()))> result;
834 std::transform(container.begin(), container.end(), std::back_inserter(result), Function);
839 template<
class C,
class P>
841 auto AllOf(
const C &container,
const P &Predicate)->bool
843 return std::all_of(container.begin(), container.end(), Predicate);
847 template<
class C,
class P>
849 auto AnyOf(
const C &container,
const P &Predicate)->bool
851 return std::any_of(container.begin(), container.end(), Predicate);
855 template<
class C,
class P>
857 auto AnyOfW(C &container,
const P &Predicate)->bool
859 return std::any_of(container.begin(), container.end(), Predicate);
863 template<
class C,
class P>
865 auto NoneOf(
const C &container,
const P &Predicate)->bool
867 return std::none_of(container.begin(), container.end(), Predicate);
871 template<
class C,
class T>
873 auto Count(
const C &container,
const T &val)
875 return std::count(container.begin(), container.end(), val);
879 template<
class C,
class P>
881 auto CountIf(
const C &container,
const P &Predicate)
883 return std::count_if(container.begin(), container.end(), Predicate);
887 template<
class C,
class P>
889 auto FindIf(C &container,
const P &Predicate)
891 return std::find_if(container.begin(), container.end(), Predicate);
895 template<
class C,
class P>
899 return std::find_if(container.rbegin(), container.rend(), Predicate);
907 template<
class C,
class P>
911 const auto it = std::find_if(container.begin(), container.end(), Predicate);
912 return it == container.end()
918 template<
class C,
class P>
919 auto EraseIf(C &container,
const P &Predicate)
921 auto rem = std::remove_if(container.begin(), container.end(), Predicate);
922 container.erase(rem, container.end());
926 template<
class C,
class P>
928 auto SelectIf(
const C &container,
const P &Predicate)
931 std::copy_if(container.begin(), container.end(), std::back_inserter(result), Predicate);
940 template<
class C,
class P>
942 std::pair<C, C>
Partition(
const C &container,
const P &Predicate)
946 std::partition_copy(container.begin(), container.end(), std::back_inserter(result_true), std::back_inserter(result_false), Predicate);
947 return std::make_pair(result_true, result_false);
954 template<
class T,
class P>
956 std::vector<std::pair<size_t, size_t>>
FindIntervals(
const std::vector<T> &vec,
const P &Predicate)
958 std::vector<std::pair<size_t, size_t>> intervals;
959 std::optional<size_t> interval_start = std::nullopt;
961 for (
size_t i = 0; i < vec.size(); i++)
963 if (Predicate(vec[i]))
970 else if (interval_start)
972 intervals.emplace_back(std::make_pair(*interval_start, i - 1));
973 interval_start = std::nullopt;
981 std::vector<T> Joined(
const std::vector<std::vector<T>> &vector_of_vectors)
983 std::vector<T> result;
984 for (
const auto &vec : vector_of_vectors)
991 template<
typename T,
typename F>
992 std::vector<T> JoinTransformed(
const std::vector<std::vector<T>> &vector_of_vectors,
const F &Function)
994 std::vector<T> result;
995 for (
const auto &vec : vector_of_vectors)
1003 template<
typename F,
typename O>
1006 return std::bind(method,
object, std::placeholders::_1);
1013 return AllOf(s, [](
unsigned char c)
std::string Lowercase(const std::string &text)
Converts text into all lowercase.
Definition: ExtSTD.h:311
void InsertBack(T &target, const S &source)
Insert the source vector to the back of target vector.
Definition: ExtSTD.h:673
std::string ToStringWithThousandSeparators(const T &input)
Converts a numeric value to string using thousand separators.
Definition: ExtSTD.h:270
auto AnyOf(const C &container, const P &Predicate) -> bool
Simplified wrapper for std::any_of.
Definition: ExtSTD.h:849
std::optional< size_t > GetIndex(const Type element, const std::vector< Type > &vector)
If an element exists in the vector, returns its index.
Definition: ExtSTD.h:375
auto EraseIf(C &container, const P &Predicate)
Simplified wrapper for std::remove_if and std::erase.
Definition: ExtSTD.h:919
size_t CountOccurrences(const std::string &text, const std::string &key_to_search)
Counts how many of specified key_to_search substrings does text contain.
Definition: ExtSTD.h:80
auto MiddleValue(const std::vector< T > &vector, const F &Function)
Finds a middle (average of min, max) value transformed by a function in a vector. ...
Definition: ExtSTD.h:589
auto Find(C &container, const T &value)
Simplified wrapper for std::find.
Definition: ExtSTD.h:823
auto Average(const std::vector< T > &vector)
Compute average element of a vector. In case of empty vector, return 0.
Definition: ExtSTD.h:615
auto Median(const std::vector< T > &vector)
Compute median value of a vector. In case of empty vector, return 0.
Definition: ExtSTD.h:657
std::string & TrimBegin(std::string &s, const std::string &t=WHITESPACES)
Trims characters from beginning of string (left).
Definition: ExtSTD.h:705
std::string ToStringWithPrecision(const T value, const int n=6)
Converts type to string with specified number of decimal digits.
Definition: ExtSTD.h:215
void MakeUppercase(char *text)
Converts text into all uppercase.
Definition: ExtSTD.h:279
void Foreach(const T &container, const F &Function)
Execute a function for every element in the container.
Definition: ExtSTD.h:485
auto FindIf(C &container, const P &Predicate)
Simplified wrapper for std::find_if.
Definition: ExtSTD.h:889
auto AllOf(const C &container, const P &Predicate) -> bool
Simplified wrapper for std::all_of.
Definition: ExtSTD.h:841
std::string ToStdString(const std::wstring &text)
Convert std::wstring to std::string.
Definition: ExtSTD.h:74
std::vector< Type > RemoveDuplicates(std::vector< Type > &vector)
Returns vector similar to input, but without duplicate elements.
Definition: ExtSTD.h:430
std::string & Trim(std::string &s, const std::string &t=WHITESPACES)
Trims from both ends of string (left & right).
Definition: ExtSTD.h:719
std::string ReplacePatternWithNumber(const std::string &base_string, const std::string &pattern, const int number)
Replaces a patter in specified string with a number.
Definition: ExtSTD.h:342
auto FindIfPtr(C &container, const P &Predicate)
Simplified wrapper for std::find_if that expects a vector of pointers as input and returns a pointer...
Definition: ExtSTD.h:909
void InsertTo(T &target, const S &source)
Insert the source container to the target container.
Definition: ExtSTD.h:687
bool Contains(const std::string &substring, const std::string &text)
Checks if the text contains substring.
Definition: ExtSTD.h:327
void ReadString(std::string &text, std::istream &str)
Reads a string from the binary stream.
Definition: ExtSTD.h:791
std::wstring ToWString(const std::string &text)
Convert single-byte std::string to std::wstring.
Definition: ExtSTD.h:68
bool IsASCII(const std::string &s)
Check std::string for non-ASCII characters.
Definition: ExtSTD.h:1011
std::vector< std::string > Parse(const std::string &text, const std::string &separators=WHITESPACES)
Parses the input text to sub strings by a given list of separators.
Definition: ExtSTD.h:735
std::string ToString(const std::vector< T > &container, const std::string &separator=", ")
Converts all values in the vector to a string and joins them using specified separator.
Definition: ExtSTD.h:233
auto MaxValue(const std::vector< T > &vector, const F &Function)
Finds a maximum value transformed by a function in a vector.
Definition: ExtSTD.h:573
auto MinValue(const std::vector< T > &vector, const F &Function)
Finds a minimal value transformed by a function in a vector.
Definition: ExtSTD.h:581
auto SelectIf(const C &container, const P &Predicate)
Copies all elements fulfilling a given condition into a new vector. Uses std::copy_if.
Definition: ExtSTD.h:928
void Read(T &val, std::istream &str)
Reads a value from the binary stream, number of bytes red is determined by a template type...
Definition: ExtSTD.h:759
Extensions to the standard libraries.
Definition: AtomicQueue.h:11
std::vector< std::pair< size_t, size_t > > FindIntervals(const std::vector< T > &vec, const P &Predicate)
Finds all intervals on the vector where a given condition holds.
Definition: ExtSTD.h:956
auto Accumulate(const std::vector< T > &vector, const T start_value)
Wrapper for std::accumulate.
Definition: ExtSTD.h:599
auto Bind1(F method, O object)
Creates binding for an object method with a single argument.
Definition: ExtSTD.h:1004
auto MinIt(const std::vector< T > &vector)
Finds a minimal value in a vector, return an iterator pointing to it.
Definition: ExtSTD.h:501
void SortAndRemoveDuplicates(std::vector< Type > &vec)
Sorts the array and removes duplicate elements.
Definition: ExtSTD.h:422
T Max(const std::vector< T > &vector)
Finds a maximum value in a vector.
Definition: ExtSTD.h:509
bool ContainsCommonElement(const std::vector< Type > &elements1, const std::set< Type > &elements2)
Check if there is at least a single common element in two vectors.
Definition: ExtSTD.h:415
auto Transformed(const C &container, F Function)
Simplified wrapper for std::transform.
Definition: ExtSTD.h:831
auto RevFindIf(C &container, const P &Predicate)
Simplified wrapper for reversed std::find_if.
Definition: ExtSTD.h:897
std::vector< IndicesType > CollectIndices(const std::vector< Type > &vector, const Type value)
Collect all indices of elements in a vector with a specified value.
Definition: ExtSTD.h:470
auto MaxIt(const std::vector< T > &vector)
Finds a maximum value in a vector, return an iterator pointing to it.
Definition: ExtSTD.h:493
std::string & TrimEnd(std::string &s, const std::string &t=WHITESPACES)
Trims characters from end of string (right).
Definition: ExtSTD.h:712
auto CountIf(const C &container, const P &Predicate)
Simplified wrapper for std::count_if.
Definition: ExtSTD.h:881
std::string BoolToString(const bool value)
Converts bool to string ("true" or "false").
Definition: ExtSTD.h:160
std::string ToStringAutoPrecision(const double value, int max_digits=6)
Converts double to string with decimal digits until max_digits are reached.
Definition: ExtSTD.h:173
std::string Uppercase(const std::string &text)
Converts text into all uppercase.
Definition: ExtSTD.h:291
bool Erase(const Type &element, std::vector< Type > &vector)
Removes an element from the vector. Returns success.
Definition: ExtSTD.h:446
std::string Replace(const std::string &text, const std::string &key_to_search, const std::string &replace_text)
Replaces all occurrences of key_to_search with replace_text in specified text.
Definition: ExtSTD.h:117
void WriteString(const std::string &text, std::ostream &str)
Writes a value to the binary stream, number of bytes written is determined by a template type...
Definition: ExtSTD.h:811
void Write(const T val, std::ostream &str)
Writes a value to the binary stream, bytes written are determined by a template type.
Definition: ExtSTD.h:775
void EmplaceBackUnique(const Type &element, std::vector< Type > &vector)
Emplace back an element if it is unique to the vector.
Definition: ExtSTD.h:695
T Min(const std::vector< T > &vector)
Finds a minimal value in a vector.
Definition: ExtSTD.h:517
auto Sum(const std::vector< T > &vector)
Sum all elements in a vector.
Definition: ExtSTD.h:607
std::string ToStringWithZeroes(const T value, const int n=6)
Converts int to string with zeros at the beginning to match specified number of digits.
Definition: ExtSTD.h:224
bool EndsWith(const std::string &ending, const std::string &text)
Checks if the text ends with a string.
Definition: ExtSTD.h:319
std::string EndWithASingleSlash(const std::string &s)
Trim the end of a string to removes forward and backward slashes (/, ) and add one single forward sla...
Definition: ExtSTD.h:727
std::pair< C, C > Partition(const C &container, const P &Predicate)
Partitions all elements based on a given condition.
Definition: ExtSTD.h:942
auto NoneOf(const C &container, const P &Predicate) -> bool
Simplified wrapper for std::none_of.
Definition: ExtSTD.h:865
void MakeLowercase(char *text)
Converts text into all lowercase.
Definition: ExtSTD.h:299
auto Count(const C &container, const T &val)
Simplified wrapper for std::count.
Definition: ExtSTD.h:873
auto AnyOfW(C &container, const P &Predicate) -> bool
Simplified wrapper for std::any_of (writable).
Definition: ExtSTD.h:857
void InsertFront(T &target, const S &source)
Insert the source vector to the front of target vector.
Definition: ExtSTD.h:680