.reference

git-svn-id: svn://ultimatepp.org/upp/trunk@10453 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-11-16 21:43:17 +00:00
parent 0c9a17e359
commit 1b80e509ae
2 changed files with 25 additions and 4 deletions

View file

@ -12,15 +12,21 @@ CONSOLE_APP_MAIN{
DUMP(min(6, 2, 7, 4));
DUMP(max(6, 2, 7, 4));
DUMP(clamp(0, 1, 10));
DUMP(clamp(1, 1, 10));
DUMP(clamp(5, 1, 10));
DUMP(clamp(10, 1, 10));
DUMP(clamp(11, 1, 10));
DUMP(findarg(3, 1, 7, 6, 3, 2));
DUMP(findarg(5, 1, 7, 6));
DUMP(decode(2, 1, "one", 2, "two", 3, "three", "?"));
DUMP(decode(5, 1, "one", 2, "two", 3, "three", "?"));
Vector<int> data, empty;
data << 10 << 5 << 11 << 9 << 2;
// 0 1 2 3 4
Vector<int> empty;
Vector<int> data = { 10, 5, 11, 9, 2 };
// 0 1 2 3 4
DUMP(FindMin(data));
DUMP(FindMin(data, 0, 4));
@ -28,7 +34,12 @@ CONSOLE_APP_MAIN{
// DUMP(Min(empty)); // This is undefined (fails in ASSERT)
DUMP(Min(empty, -99999));
int mul = 1;
Accumulate(data, [&](int x) { mul *= x; });
DUMP(mul);
DUMP(Sum(data));
DUMP(FindMax(data));
DUMP(FindMax(SubRange(data, 3, 2)));
DUMP(Max(data));
@ -39,4 +50,13 @@ CONSOLE_APP_MAIN{
Vector<String> s = Split("one;two;three", ';');
DUMP(Sum(s, ""));
data = { 5, 7, 9, 9, 14, 20, 23, 50 };
// 0 1 2 3 4 5 6 7
DUMP(FindLowerBound(data, 9));
DUMP(FindUpperBound(data, 9));
DUMP(FindBinary(data, 9));
DUMP(FindLowerBound(data, 10));
DUMP(FindUpperBound(data, 10));
DUMP(FindBinary(data, 10));
}