summaryrefslogtreecommitdiff
path: root/tnslc/vector.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/vector.tnsl')
-rw-r--r--tnslc/vector.tnsl38
1 files changed, 38 insertions, 0 deletions
diff --git a/tnslc/vector.tnsl b/tnslc/vector.tnsl
new file mode 100644
index 0000000..529e3a2
--- /dev/null
+++ b/tnslc/vector.tnsl
@@ -0,0 +1,38 @@
+struct Vector {
+ ~void data,
+ uint
+ count,
+ size,
+ _elsz
+}
+
+uint VECTOR_MIN_ELEMENTS = 4
+~void NULL = 0
+
+~uint8 NUM_STR = "Num %d\n\0"
+
+/; method Vector
+
+ /; init (uint elsz)
+ self._elsz = elsz
+ self.size = VECTOR_MIN_ELEMENTS
+ self.count = 0
+ self.data = _alloc(self.size * self._elsz)
+ ;/
+
+ /; get (uint index) [~void]
+ /; if (index !< self.count)
+ return NULL
+ ;/
+
+ return self.data + index * self._elsz
+ ;/
+
+ /; end
+ self.count = 0
+ self.size = 0
+ self._elsz = 0
+ _delete(self.data)
+ ;/
+;/
+