Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 73577b7

Browse files
committed
Added size() and toString() functions
1 parent 24167c4 commit 73577b7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

CIQVec.mc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Well, welcome to the source code of Vec!
22
import Toybox.Lang;
3-
import Toybox.System;
3+
using Toybox.System;
44
using Toybox.Math;
55

66
module CIQVec {
@@ -51,6 +51,20 @@ module CIQVec {
5151
}
5252
return slice;
5353
}
54+
55+
function size() as Number {
56+
return self.indexes.size();
57+
}
58+
59+
//! Returns a string version of the vector.
60+
function toString() as String {
61+
var result = "[";
62+
for (var i = 0; i <= self.indexes.size(); i++) {
63+
result = result + self.content[self.indexes[i]];
64+
}
65+
result = result + "]";
66+
return result;
67+
}
5468
}
5569

5670
/// A simple class for an exception

0 commit comments

Comments
 (0)