Skip to content
SalvakiyaPublic

About

Data Structures implemented with LuaJIT's FFI

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

SalDS

Data Structures implemented with LuaJIT's FFI

Current data structures are..

  • Vector(dynamic array)
  • Hashtable

The Hashtable is not ready for use and does contain bugs. The Vector SHOULD be ready for use.

Example usage:

local salds = require("salds")
local ffi = require("ffi")
ffi.cdef[[
  struct Position{
    float x,y;
  };
]]

vec = salds.new_vec("struct Position")
vec:push(ffi.new("struct Position", 10, 20))
foo = vec:pop()

iteration - these functions are provided to help with the fact that these indexes start at 0 and not 1 like lua arrays

--get the pointer to the c data
local pointer = vec:ptr()

--itersize() will return the size-1
for i = 0, vec:itersize() do
  print(pointer[i])
end

--or iterate over I like so
for i in vec:iterindex() do
  print(pointer[i])
end

About

Data Structures implemented with LuaJIT's FFI

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages