From 9faeade3e59d737d3f87bc3804d8ceb5da80bc34 Mon Sep 17 00:00:00 2001 From: koldo Date: Tue, 23 Apr 2019 07:16:16 +0000 Subject: [PATCH] Functions4U: More utility functions git-svn-id: svn://ultimatepp.org/upp/trunk@13028 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Functions4U/Functions4U.h | 15 +++++++++++++-- bazaar/Functions4U/Functions4U_Gui.cpp | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bazaar/Functions4U/Functions4U.h b/bazaar/Functions4U/Functions4U.h index a0e238ffb..ef521ac4c 100644 --- a/bazaar/Functions4U/Functions4U.h +++ b/bazaar/Functions4U/Functions4U.h @@ -667,14 +667,23 @@ void Shuffle(C &data, int randomSeed = Null) { } template -void FindAdd(Range& r, const V& value, int from = 0) -{ +void FindAdd(Range& r, const V& value, int from = 0) { for(int i = from; i < r.GetCount(); i++) if(r[i] == value) return; r.Add(value); } +template +bool Compare(Range& a, Range& b, int from = 0) { + if (a.GetCount() != b.GetCount()) + return false; + for(int i = from; i < a.GetCount(); i++) + if(a[i] != b[i]) + return false; + return true; +} + class RealTimeStop { typedef RealTimeStop CLASSNAME; public: @@ -874,4 +883,6 @@ int LevenshteinDistance(const char *s, const char *t); int DamerauLevenshteinDistance(const char *s, const char *t, int alphabetLength = 256); int SentenceSimilitude(const char *s, const char *t); +#define x_(y) String(y) + #endif diff --git a/bazaar/Functions4U/Functions4U_Gui.cpp b/bazaar/Functions4U/Functions4U_Gui.cpp index 1cce00490..659487643 100644 --- a/bazaar/Functions4U/Functions4U_Gui.cpp +++ b/bazaar/Functions4U/Functions4U_Gui.cpp @@ -148,4 +148,4 @@ int GetEditWidth(const String str) { } -#endif +#endif \ No newline at end of file