Functions4U: More utility functions

git-svn-id: svn://ultimatepp.org/upp/trunk@13028 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2019-04-23 07:16:16 +00:00
parent b2fdd9dee0
commit 9faeade3e5
2 changed files with 14 additions and 3 deletions

View file

@ -667,14 +667,23 @@ void Shuffle(C &data, int randomSeed = Null) {
}
template <class Range, class V>
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 <class Range>
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

View file

@ -148,4 +148,4 @@ int GetEditWidth(const String str) {
}
#endif
#endif