- Table of Contents
- Why does this even exist?
- Features
- Installation
- Usage
- API
- TODO For me
- Found a Bug?
- Contribution
- LICENSE
- References
I needed to use queues while developing some libraries and i was like why dont i make this and put it in github.
| Type | Enqueue Complexity | Dequeue Complexity | Space Complexity |
|---|---|---|---|
| FIFO Queue | O(1) |
O(1) |
O(n) |
| Priority Max | O(log n) |
O(log n) |
O(n) |
Check out time complexities: Desmos Time Complexities
To install this to your computer you have this options;
- Clone this repository by running following command
git clone https://github.com/Cod2rDude/queues
- Get the latest release of .rbxm file from releases
- Or add this as a submodule to your project
git submodule add https://github.com/Cod2rDude/queues [PATH]
Wally will be added in future (I hope).
local queues = require(path.to.module)
local size = 10 -- 2 <= size <= 1024
local myFifoQueue = queues.fifo.new(size)
-- enqueing first item
myFifoQueue:enqueue(5)
-- enqueing second item
myFifoQueue:enqueue(6)
-- dequeing will return 5 since we added 5 first
print(myFifoQueue:dequeue()) -- 5
-- dequeueing again will return 6 because we added 6 after 5
print(myFifoQueue:dequeue()) local queues = require(path.to.module)
local size = 10 -- 2 <= size <= 1024
local myPriorityQueue = queues.priorityMax.new(size)
-- object, priority
myPriorityQueue:enqueue("low", 1)
myPriorityQueue:enqueue("high", 100)
myPriorityQueue:enqueue("mid", 50)
print(myPriorityQueue:dequeue()) -- high
print(myPriorityQueue:dequeue()) -- mid
print(myPriorityQueue:dequeue()) -- lowPlease check out source code for further info about api. (Sorry!)
(I plan to make a project to autoconvert it to a documentation automatically.)
- Add a consumer loop function to both queues.
- Add a way to search for a specific item in both queues.
- Let user remove a specific item (either an index or order or just an object) in both queues.
- Add raw iteration to both queues.
If you encounter any issues or unexpected behavior, please let me know! Your feedback helps make this library more stable.
- Check the existing issues to see if it has already been reported.
- If not, open a new issue and describe the problem.
- Provide a small code snippet to reproduce the bug if possible.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
To maintain the stability of the library, direct commits to the main branch are restricted. Please follow the workflow below to suggest changes:
- Fork the Project: Create your own copy of this repository.
- Create a Feature Branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature' - Push to branch:
git push origin feature/AmazingFeature
- Open a Pull Request: Navigate to the original repository and click "New Pull Request". Describe your changes in detail so they can be reviewed.
Once your Pull Request is merged, GitHub will automatically list you in the official "Contributors" section of the repository. (i guess so)
After a successful merge, I will also manually add your name and contribution to the table below!
We appreciate contributions you will make but we will also highly appreciate you to follow our guidelines while contributing.
- Of course make sure your code is efficient.
- No nsfw links, swearing or anything like those.
- Maybe follow the coding style we do.
- That's it!
This project is licensed under The MIT License
- Big-O Cheatsheet (n.d.) Know Thy Complexities! Retrieved from https://www.bigocheatsheet.com/
- Wikipedia contributors. (2024, November 20). Big O notation. In Wikipedia, The Free Encyclopedia. Retrieved from https://en.wikipedia.org/wiki/Big_O_notation
- Wikipedia contributors. (2024, November 25). Circular buffer. In Wikipedia, The Free Encyclopedia. Retrieved from https://en.wikipedia.org/wiki/Circular_buffer
- Wikipedia contributors. (2024, December 1). FIFO (computing and electronics). In Wikipedia, The Free Encyclopedia. Retrieved from https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
- Wikipedia contributors. (2024, December 15). Heap (data structure). In Wikipedia, The Free Encyclopedia. Retrieved from https://en.wikipedia.org/wiki/Heap_(data_structure)
- GeeksforGeeks (2025, October 21). Binary Heap Retrieved from https://www.geeksforgeeks.org/dsa/binary-heap/