diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-25 16:37:07 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-25 16:37:07 -0400 |
commit | 00f4940ff1c19f3659779b2db078b85f178cb5ab (patch) | |
tree | c7aca037e64dbe184085e7342c187eef5ffb3c40 /tnslc/iterator.tnsl | |
parent | 8f86708daa697274a39f8b0af42291a4ed4573eb (diff) |
More tests, dec and inc postfix
Diffstat (limited to 'tnslc/iterator.tnsl')
-rw-r--r-- | tnslc/iterator.tnsl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tnslc/iterator.tnsl b/tnslc/iterator.tnsl new file mode 100644 index 0000000..19dda8c --- /dev/null +++ b/tnslc/iterator.tnsl @@ -0,0 +1,39 @@ +struct Iterator { + ~void data, + int size, + current, + _elsz +} + +/; method Iterator + + /; init (~void data, int count, int elsz) + self.data = data + self.size = size + self._elsz = elsz + self.current = 0 + ;/ + + /; next (int count) + self.current = self.current + count + /; if (self.current >= self.size) + self.current = self.size + ;/ + ;/ + + /; prev (int count) + self.current = self.current - count + /; if (self.current < 0) + self.current = 0 + ;/ + ;/ + + /; get [~void] + return self.data + current * _elsz + ;/ + + /; end [bool] + return self.current >= self.size + ;/ + +;/ |