1

array demo

This commit is contained in:
2022-07-18 21:55:36 +02:00
parent f5a4a66207
commit 3d76162d8a
4 changed files with 75 additions and 6 deletions

View File

@ -0,0 +1,41 @@
#include "user/demo/ArrayDemo.h"
void ArrayDemo::run() {
Array<int, 10> arr1 {};
Array<int, 10> arr2 {};
Array<Thread*, 10> arr3 {};
kout.lock();
kout.clear();
kout << "Adding..." << endl;
for (int i = 0; i < 10; ++i) {
arr1[i] = i;
}
kout << "Iterator printing arr1:" << endl;
for (int i : arr1) {
kout << i << " ";
}
kout << endl;
kout << "Swapping arr1 and arr2..." << endl;
arr1.swap(arr2);
kout << "Iterator printing arr1:" << endl;
for (int i : arr1) {
kout << i << " ";
}
kout << endl;
kout << "Iterator printing arr2:" << endl;
for (int i : arr2) {
kout << i << " ";
}
kout << endl;
// arr1.swap(arr3); // Not possible as type/size has to match
kout.unlock();
scheduler.exit();
}