mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-25 08:30:29 +00:00
CPunch
0beeee0fdf
ISTRING_RESERVED was added to iStrings call & callCFunction now use memmove instead of memcpy Additionally, added cosmoO_setUserP, cosmoO_getUserP, cosmoO_setUserI and cosmoO_getUserI to the C API.
42 lines
665 B
Plaintext
42 lines
665 B
Plaintext
proto Vector
|
|
function __init(self)
|
|
self.vector = {}
|
|
self.x = 0
|
|
end
|
|
|
|
function push(self, val)
|
|
self.vector[self.x++] = val
|
|
end
|
|
|
|
function pop(self)
|
|
return self.vector[--self.x]
|
|
end
|
|
|
|
function __index(self, key)
|
|
return self.vector[key]
|
|
end
|
|
|
|
function __iter(self)
|
|
self.iterIndex = 0
|
|
|
|
return self
|
|
end
|
|
|
|
function __next(self)
|
|
if self.iterIndex > self.x then
|
|
return nil
|
|
end
|
|
|
|
return vector[self.iterIndex++]
|
|
end
|
|
end
|
|
|
|
var vector = Vector()
|
|
|
|
for (var i = 0; i < 100000; i++) do
|
|
vector.push(i)
|
|
end
|
|
|
|
for i in vector do
|
|
print(i)
|
|
end |