luaguides

Tutorial series

Lua Data Structures

6 tutorials — follow in order for the best learning path.

  1. Stacks and Queues in Lua: Implementations and Performance

    Build efficient stacks and queues in Lua using plain tables. Covers push and pop, the O(n) trap of table.remove(t, 1), and circular buffer performance.

  2. Implementing Sets in Lua Using Tables and Metatables

    Hands-on guide to implementing sets in Lua: table keys as members, true sentinel values, union, intersection, difference, and read-only proxies.

  3. Singly and Doubly Linked Lists in Lua

    Learn how to implement singly and doubly linked lists in Lua using tables, with performance comparisons and practical examples.

  4. Binary trees and binary search trees in Lua

    Learn how to implement binary trees and binary search trees in Lua with clear explanations and runnable code examples.

  5. Priority Queues and Heaps in Lua

    Learn how to implement priority queues and binary heaps in Lua using tables, with practical examples for task scheduling and event queues.

  6. Graph Representations in Lua: Adjacency Matrix and List

    Learn two standard graph representations in Lua: adjacency matrices for dense graphs and adjacency lists for sparse graphs, with BFS and DFS traversal examples.