Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38043ec

Browse files
+ Array + MicromlWifiIndoorPositioningExample
1 parent 305fd51 commit 38043ec

File tree

23 files changed

+305
-1365
lines changed

23 files changed

+305
-1365
lines changed

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
__src
2+
_src
23
__examples
34
__ignore
45
src/.vscode
56
node_modules
67
yarn-error.log
8+
*.patch
9+
model.h

‎.idea/workspace.xml‎

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#include <ArduinoUnit.h>
2+
#include <eDataStructures.h>
3+
4+
5+
using namespace Eloquent::DataStructures;
6+
7+
8+
/**
9+
* The Array class needs 2 template arguments:
10+
* 1. value datatype
11+
* 2. max number of entries
12+
*/
13+
14+
test(subscript_set) {
15+
Array<int, 10> array(0);
16+
17+
array[0] = 10;
18+
array[1] = 20;
19+
20+
assertEqual(array[0], 10);
21+
assertEqual(array[1], 20);
22+
}
23+
24+
test(push_int) {
25+
Array<int, 10> array(0);
26+
27+
array.push(10);
28+
array.push(20);
29+
30+
assertEqual(array[0], 10);
31+
assertEqual(array[1], 20);
32+
// if the key doesn't exists, 0 is returned
33+
assertEqual(array[2], 0);
34+
}
35+
36+
test(push_string) {
37+
Array<String, 10> array("");
38+
39+
array.push("abc");
40+
array.push("Hello world");
41+
42+
assertTrue(array[0].equals("abc"));
43+
assertTrue(array[1].equals("Hello world"));
44+
assertTrue(array[2].equals(""));
45+
}
46+
47+
test(prevents_overflow) {
48+
Array<int, 2> array(0);
49+
50+
array.push(10);
51+
array.push(20);
52+
// this will be ignored
53+
array.push(30);
54+
55+
assertEqual(array[0], 10);
56+
assertEqual(array[1], 20);
57+
// if you push when the max number of entries
58+
// has been reached, it is ignored
59+
assertEqual(array.length(), 2);
60+
}
61+
62+
test(index_of) {
63+
Array<int, 2> array(0);
64+
65+
array[0] = 10;
66+
array[1] = 20;
67+
68+
assertEqual(array.indexOf(10), 0);
69+
assertEqual(array.indexOf(20), 1);
70+
assertEqual(array.indexOf(30), sqrt(-1));
71+
}
72+
73+
test(get_min) {
74+
Array<int, 5> array(0);
75+
76+
array[0] = 20;
77+
array[1] = 30;
78+
array[2] = 40;
79+
array[3] = 50;
80+
array[4] = 10;
81+
82+
assertEqual(array.getMin(), 10);
83+
}
84+
85+
test(get_max) {
86+
Array<int, 5> array(0);
87+
88+
array[0] = 20;
89+
array[1] = 30;
90+
array[2] = 40;
91+
array[3] = 50;
92+
array[4] = 10;
93+
94+
assertEqual(array.getMax(), 50);
95+
}
96+
97+
test(get_sum) {
98+
Array<int, 5> array(0);
99+
100+
array[0] = 10;
101+
array[1] = 20;
102+
array[2] = 30;
103+
array[3] = 40;
104+
array[4] = 50;
105+
106+
assertEqual(array.getSum(), 150);
107+
}
108+
109+
test(get_argmin) {
110+
Array<int, 5> array(0);
111+
112+
array[0] = 20;
113+
array[1] = 30;
114+
array[2] = 40;
115+
array[3] = 50;
116+
array[4] = 10;
117+
118+
assertEqual(array.argmin(), 4);
119+
}
120+
121+
test(get_argmax) {
122+
Array<int, 5> array(0);
123+
124+
array[0] = 20;
125+
array[1] = 30;
126+
array[2] = 40;
127+
array[3] = 50;
128+
array[4] = 10;
129+
130+
assertEqual(array.argmax(), 3);
131+
}
132+
133+
134+
void setup() {
135+
Serial.begin(115200);
136+
}
137+
138+
139+
void loop() {
140+
Test::run();
141+
}

‎examples/HashMapExample/HashMapExample.ino‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using namespace Eloquent::DataStructures;
66

77

88
/**
9-
* The HashMap needs 3 template arguments:
9+
* The HashMap class needs 3 template arguments:
1010
* 1. key datatype
1111
* 2. value datatype
1212
* 3. max number of entries
@@ -65,7 +65,7 @@ test(prevents_overflow) {
6565

6666

6767
void setup() {
68-
Serial.begin(9600);
68+
Serial.begin(115200);
6969
}
7070

7171

‎examples/ML/SVM.ino‎

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /