CatStack and CatQueue
Posted: Tue Aug 16, 2011 12:43 am
CatStack and CatQueue are stack and queue implementations I made in Lua.
It is pretty self explanatory, most commands you see in other languages are there. I also think it is a very simple example of OO with Lua for people to look at.
So without further adieu:
Download the library from bitbucket! (comes with a rudimentary unit-test too)
I understand this is a fairly mundane library, but stacks and queues have many uses. And, I'd like some peer review on the style/performance of this code.
I also made sure there was a way to deep-copy tables when you peek/top your stack for happy viewing.
Oh, and they have pretty prints
It is pretty self explanatory, most commands you see in other languages are there. I also think it is a very simple example of OO with Lua for people to look at.
So without further adieu:
Download the library from bitbucket! (comes with a rudimentary unit-test too)
I understand this is a fairly mundane library, but stacks and queues have many uses. And, I'd like some peer review on the style/performance of this code.
I also made sure there was a way to deep-copy tables when you peek/top your stack for happy viewing.
Oh, and they have pretty prints
Code: Select all
CatStack
6: MATHEMATICAL!
5: adventure time!
4: kittens
3: 5
2: 5
1: 5
Code: Select all
CatQueue
.
out / \
|
0: 5
1: 5
2: 5
3: kittens
4: adventure time!
5: MATHEMATICAL!
.
in / \
|