.reference

git-svn-id: svn://ultimatepp.org/upp/trunk@10643 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-01-05 07:37:06 +00:00
parent 66e00d369e
commit 48c2d776b9
4 changed files with 16 additions and 5 deletions

View file

@ -24,16 +24,21 @@ CONSOLE_APP_MAIN{
DUMP(decode(2, 1, "one", 2, "two", 3, "three", "?"));
DUMP(decode(5, 1, "one", 2, "two", 3, "three", "?"));
Vector<int> empty;
Vector<int> data = { 10, 5, 11, 9, 2 };
// 0 1 2 3 4
Vector<int> data = { 10, 5, 11, 9, 2, 11 };
// 0 1 2 3 4 5
DUMP(FindIndex(data, 11));
DUMP(FindMin(data));
DUMP(FindMin(data, 0, 4));
DUMP(Min(data));
Vector<int> empty;
// DUMP(Min(empty)); // This is undefined (fails in ASSERT)
DUMP(Min(empty, -99999));
DUMP(Count(data, 11));
DUMP(CountIf(data, [=](int c) { return c >= 5; }));
struct {
int mul = 1;
void operator()(int x) { mul *= x; };

View file

@ -7,7 +7,7 @@ struct Model { // some computation model that is not stateless, abstract definit
virtual int Compute() = 0;
};
struct Model1 : Model { // concrete model (there would be more)
struct Model1 : Model { // concrete model (there would be more that this one)
int n;
virtual void Start(int i) { n = i; }
@ -19,9 +19,11 @@ CONSOLE_APP_MAIN
Vector<int> data;
data.SetCount(3000);
// generate data using some model:
CoWorkerResources<One<Model>> res;
for(auto& r : res)
r.Create<Model1>();
r.Create<Model1>(); // all should be the same
CoPartition(0, data.GetCount(), [&data, &res](int l, int h) {
Model& m = *~res; // gets resource unique for worker

View file

@ -1,3 +1,5 @@
description "CoWorkerResources provide per-worker-thread context\377";
uses
Core;

View file

@ -34,6 +34,7 @@ CONSOLE_APP_MAIN
DUMP(Format("%n", 1234567.89));
DUMP(Format("%,n", 1234567.89));
DUMP(Format("%+n", 1234567.89));
DUMP(Format("%+n", -1234567.89));
DUMP(Format("%2,n", 123.456));
DUMP(Format("%2,n", 123));
DUMP(Format("%2!,n", 123));
@ -52,6 +53,7 @@ CONSOLE_APP_MAIN
DUMP(Format("%[3%1:one;2:two;3:three;another]s", 20));
DUMP(Format("%month", 6));
DUMP(Format(LNG_('C','S','C','Z'), "%month", 6));
DUMP(Format("%Month", 6));
DUMP(Format("%MONTH", 6));
DUMP(Format("%mon", 6));