This is just a repository for data structures that I'm usually using with GoLang These data structures are my implementations and I'm most of the time using them for leetcode.
For each data structure there is a test file where all the tests for that particular data structures are written.
For running all the tests please run the test.sh
scripts from the root of the project.
./test.sh
So, I'm aiming for all my data structures to be generic, since I want to use them in different contexts.
While initializing the queue, you can use the utility function NewArrayQueue
which will return a new instance of the ArrayQueue
implementation
queue := NewArrayQueue[int]()
queue.Enqueue(1)
Dequeues the front Element and returns it
dequeuedElement := queue.Dequeue()
Returns the front Element of the ArrayQueue
without removing it.
peekedElement := queue.Peek()
Removes all the elements from the Queue.
queue.Clear()
isEmpty := queue.IsEmpty()
size := queue.Size
This will give you the slice instance that was created once initializing the ArrayQueue
elements := queue.Elements
While initializing the stack, you can use the utility function NewArrayStack
which will return a new instance of the ArrayStack
implementation
stack := NewArrayStack[int]()
stack.Push(1)
Removes the last Element from the Stack and returns it
poppedElement := stack.Pop()
Returns the last Element from the Stack without removing it
lastElement := stack.Peek()
Removes all the Elements from the stack
stack.Clear()
isEmpty := stack.IsEmpty()
I'm not looking for contributors, as this is just my hobby repository where I'm keeping all of the data structures that I need, but of course if you spot bugs, or any issues feel free to open a PR or issue, I'll be happy to review it.