mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
fix bytearray:insert (#594)
This commit is contained in:
parent
a46aafa562
commit
25f4c7fbdd
2 changed files with 7 additions and 1 deletions
|
|
@ -28,3 +28,9 @@ assert(#arr == arr:get_capacity())
|
||||||
|
|
||||||
arr = Bytearray({0, 2, 7, 1, 16, 75, 25})
|
arr = Bytearray({0, 2, 7, 1, 16, 75, 25})
|
||||||
assert(arr[6] == 75)
|
assert(arr[6] == 75)
|
||||||
|
|
||||||
|
arr:insert(2, {5, 6})
|
||||||
|
|
||||||
|
assert(arr[#arr] == 25)
|
||||||
|
assert(arr[2] == 5)
|
||||||
|
assert(arr[3] == 6)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ local function insert(self, index, b)
|
||||||
if self.size + elems > self.capacity then
|
if self.size + elems > self.capacity then
|
||||||
grow_buffer(self, elems)
|
grow_buffer(self, elems)
|
||||||
end
|
end
|
||||||
for i=self.size, index - 1, -1 do
|
for i = self.size - 1, index - 1, -1 do
|
||||||
self.bytes[i + elems] = self.bytes[i]
|
self.bytes[i + elems] = self.bytes[i]
|
||||||
end
|
end
|
||||||
if _type(b) == "number" then
|
if _type(b) == "number" then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue