Skip to content

tahseenjamal/circularbuffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

This program can be used to create a unique ring "buffer" stack of stack size "length"

When you add element in stack, it checks if alreaedy present. In that case discard and return false else add and return true

both array and map are used. Array is used to track element sequence to delete oldest element just in case the size of stack increases when a new element is added

maps are faster to search an exiting key as Go doesn't have built in function to find a elements and looping to find element is slow

Note the stack never grows beyond "length" elements. If it grows, the earlier elements are trimmed to maintain the length of stack as defined during initialisation

Note that you can define string or int or any other variable type just when you add to the stack. This is because the program uses interface{} and the moment you add the first element, it automatically gets to know whether you are chosing string, int, byte or whatever type

Yes, interface is a powerful feature of Go Lang and I love it :-)

About

Circular Buffer for various use cases

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages