0

Are there any stl implementations for lua? I understand we can use table instead of the stl facilities when programming in lua,but it is really not friendly to be used,so I am wondering the stl implementations in lua,especially the vector,map,list,set.

10
  • 4
    No, and rightfully so. The concepts from the STL translate very badly over to a dynamically typed language like Lua. Embrace the flexibility offered by tables and try to understand how to use their specific strengths to work efficiently and you will probably not miss it much. Commented Jul 15, 2014 at 15:30
  • 1
    What operations on which structures are you having trouble with? Commented Jul 15, 2014 at 16:19
  • 1
    Vector/list: use tables with numeric keys. Map: tables with any keys. Set: tables with the set contents as keys and a placeholder value (like true) as values. Commented Jul 15, 2014 at 17:10
  • @ColonelThirtyTwo you should make that into an answer, I was going to then saw your comment
    – Oliver
    Commented Jul 16, 2014 at 1:29
  • @Schollii The STL is more than just containers. Commented Jul 16, 2014 at 6:57

1 Answer 1

2

A library exists to use C++ containers in Lua. See :

But you can also use containers written in pure Lua :

People in comments recommend you to use the Lua table structure as you need. If you need only simple data types and algorithms (for instance set with insertion, removal and test), you should. But if you need more complex algorithms, these libraries are a good choice.

Not the answer you're looking for? Browse other questions tagged or ask your own question.