PIVector doc
This commit is contained in:
32
main.cpp
32
main.cpp
@@ -2,30 +2,12 @@
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
PIThreadNotifier n;
|
||||
int cnt1 = 0;
|
||||
int cnt2 = 0;
|
||||
int cnt3 = 0;
|
||||
PIThread t1([&n, &cnt1](){n.wait(); cnt1++; piMSleep(1);}, true);
|
||||
PIThread t2([&n, &cnt2](){n.wait(); cnt2++; piMSleep(2);}, true);
|
||||
piCout << "created";
|
||||
piMSleep(10);
|
||||
piCout << "unlock" << cnt1 << cnt2 << cnt3;
|
||||
n.notifyOnce(); cnt3++;
|
||||
piMSleep(10);
|
||||
piCout << "unlock" << cnt1 << cnt2 << cnt3;
|
||||
n.notifyOnce(); cnt3++;
|
||||
piMSleep(10);
|
||||
piCout << "run" << cnt1 << cnt2 << cnt3;
|
||||
PIThread t3([&n, &cnt3](){n.notifyOnce(); cnt3++; piMSleep(1);}, true);
|
||||
piMSleep(20);
|
||||
t3.stop();
|
||||
piMSleep(100);
|
||||
piCout << "exit" << cnt1 << cnt2 << cnt3;
|
||||
PIByteArray ba = PIByteArray::fromHex("00aabbcc");
|
||||
PIByteArray ba2 = ba.getRange(1, 2);
|
||||
piCout << ba2.toHex();
|
||||
// m.unlock();
|
||||
// piMSleep(10);
|
||||
PIVector <int> v(5, [](size_t i){return i*2;});
|
||||
v.prepend({1, 2, 3});
|
||||
piCout << v;
|
||||
piCout << v.reduce<int>([](int v, int s){return v+s;});
|
||||
piCout << v.reduce<PIString>([](int v, PIString s){return s+PIString::fromNumber(v);});
|
||||
PIStringList sl = v.map<PIString>([](int v){return PIString::fromNumber(v);});
|
||||
piCout << sl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user