summaryrefslogtreecommitdiff
path: root/tnslc/utils
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/utils')
-rw-r--r--tnslc/utils/algo.tnsl7
-rw-r--r--tnslc/utils/vector.tnsl35
2 files changed, 42 insertions, 0 deletions
diff --git a/tnslc/utils/algo.tnsl b/tnslc/utils/algo.tnsl
index 73cfb7f..35ac35c 100644
--- a/tnslc/utils/algo.tnsl
+++ b/tnslc/utils/algo.tnsl
@@ -200,6 +200,13 @@
return out.as_cstr()
;/
+/; stradd(~uint8 a, ~uint8 b) [~uint8]
+ Vector out
+ out.from_cstr(a)
+ out.push_cstr(b)
+ return out.as_cstr()
+;/
+
/; unquote_cha(~uint8 cha) [uint8]
/; if (cha` !== '\\')
return cha`
diff --git a/tnslc/utils/vector.tnsl b/tnslc/utils/vector.tnsl
index d00d698..38c45fc 100644
--- a/tnslc/utils/vector.tnsl
+++ b/tnslc/utils/vector.tnsl
@@ -67,6 +67,22 @@ uint VECTOR_MAX_GROW = 256
;/
/; pop
+ self.remove(self.count - 1)
+ ;/
+
+ /; remove (int index)
+ /; if (index < 0 || index !< self.count)
+ return
+ ;/
+
+ /; if (self.count > 1)
+ /; loop (int i = index * self._elsz; i < (self.count - 1) * self._elsz) [i++]
+ ~uint8 to = self.data + i
+ ~uint8 from = self.data + i + self._elsz
+ to` = from`
+ ;/
+ ;/
+
self.count--
/; if (self.count < self.size / 2)
@@ -96,6 +112,25 @@ uint VECTOR_MAX_GROW = 256
self._elsz = 0
_delete(self.data)
;/
+
+ /; copy [Vector]
+ Vector out
+
+ out.init(self._elsz)
+ /; loop (int i = 0; i < self.count) [i++]
+ ~int tmp = self.get(i)
+ out.push(tmp)
+ ;/
+
+ return out
+ ;/
+
+ /; back [~void]
+ /; if (self.count > 0)
+ return self.get(self.count - 1)
+ ;/
+ return NULL
+ ;/
;/