{"id":"gigahd/simplesuite","name":"simplesuite","scope":"gigahd","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.3.1","latest":"0.3.1","versions":["0.1.0","0.2.0","0.3.0","0.3.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"689845d231c753072f23a86da5c63768526d0bd3ea6957977ed51d03d2a426bf","likes":0,"downloads":0,"install":"forest install gigahd/simplesuite","url":"https://forest.dev/p/roblox/gigahd/simplesuite","files":"https://api.forest.dev/ai/package/roblox/gigahd/simplesuite/files","readme":"# SimpleSuite\n\nA Collection of simple Data Structures that I use in my games.\n\n## Includes\n\n- SimpleStack\n- SimpleQueue (O(1) amortized enqueue/dequeue)\n- SimpleList\n- SimplePriorityQueue (binary heap)\n\nEvery structure shares a consistent surface: `Size`, `IsEmpty`, `Clear`, `Has`,\n`Remove` (removes the first element equal to a value, returning a boolean),\n`RemoveWhere` (removes the first element satisfying a predicate, returning the\nremoved element or nil), and `Iterator`, plus its own operations. Each\nconstructor takes an optional `capacity` to pre-reserve the backing array. (On\n`List`, removal by index is `RemoveAt`; `Remove` is by value, like the other\nstructures.)\n\n`RemoveWhere` is the one to reach for when you only know a sub-value:\n\n```lua\nlocal players = SimpleSuite.List()\nplayers:Append({ id = 1, name = \"Ana\" })\nplayers:Append({ id = 2, name = \"Bo\" })\n\nlocal removed = players:RemoveWhere(function(p)\n    return p.id == 2\nend)\nprint(removed.name) --> Bo\n```\n\nOn `PriorityQueue`, `RemoveWhere` removes the **highest-priority** match (the\nsame element `Find` would return).\n\nGet it on [Wally](https://wally.run/package/gigahd/simplesuite)\n\n## Usage\n\n> **Note:** As of `0.3.0` the structures are metatable-based and use\n> **method (colon) call syntax**, e.g. `stack:Push(x)`. This is a breaking\n> change from `0.2.x`, which used dot calls.\n\n```lua\nlocal SimpleSuite = require(path.to.SimpleSuite)\n\n-- Stack (LIFO)\nlocal stack = SimpleSuite.Stack()\nstack:Push(1)\nstack:Push(2)\nprint(stack:Pop()) --> 2\n\n-- Queue (FIFO)\nlocal queue = SimpleSuite.Queue()\nqueue:Enqueue(\"a\")\nqueue:Enqueue(\"b\")\nprint(queue:Dequeue()) --> a\n\n-- List\nlocal list = SimpleSuite.List()\nlist:Append(10)\nlist:Prepend(5)\nprint(list:Get(1)) --> 5\n\n-- PriorityQueue (comparator: return true when `a` should leave before `b`)\nlocal pq = SimpleSuite.PriorityQueue(function(a, b)\n    return a < b -- min-heap\nend)\npq:Enqueue(3)\npq:Enqueue(1)\nprint(pq:Dequeue()) --> 1\n\n-- Iterate any structure\nfor index, value in stack:Iterator() do\n    print(index, value)\nend\n\n-- Pre-reserve capacity for a known workload\nlocal big = SimpleSuite.List(10_000)\n```\n","readmeTruncated":false}