struct Vector { ~void data, uint count, size, _elsz } uint VECTOR_MIN_ELEMENTS = 4 uint VECTOR_MAX_GROW = 256 ~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) ;/ /; _grow (uint i) self.size = self.size + i self.data = _realloc(self.data, self.size * self._elsz) ;/ /; get (uint index) [~void] /; if (index !< self.count) return NULL ;/ return self.data + index * self._elsz ;/ /; push (~void el) /; if (self.size == self.count + 1) /; if (self.size < VECTOR_MAX_GROW) self._grow(self.size) ;; else self._grow(VECTOR_MAX_GROW) ;/ ;/ ~void start = self.data + self.count * self._elsz /; loop (int i = 0; i < self._elsz) [i++] ~uint8 to = start + i ~uint8 from = el + i to` = from` ;/ self.count++ ;/ /; push_char (uint8 ch) self.push(~ch) ;/ /; push_cstr(~uint8 ch) /; loop (ch` !== 0) [ch++] self.push(ch) ;/ self.push(ch) ;/ /; as_cstr [~uint8] ~uint8 z = self.data + self.count z` = 0 return self.data ;/ /; end self.count = 0 self.size = 0 self._elsz = 0 _delete(self.data) ;/ ;/ # Artifacts struct Artifact { ~~uint8 strings, uint size, count } /; method Artifact /; init self.size = VECTOR_MIN_ELEMENTS self.count = 0 self.strings = _alloc(self.size * 8) ;/ ;/