github.com/nsf/ringbuffer
Package provides fixed length FIFO ring buffer functionality. You can use a generic data structure with methods, which is forced to use slices due to Go language limitations (no generic array lengths): Or you can use generic functions with your own state variables. Here you can use plain arrays and integer types of arbitrary size: The logic is the simplest implementation straight from wikipedia: https://en.wikipedia.org/wiki/Circular_buffer. In short: there are read and write pointers as integer indices and a buffer of capacity+1 space. An extra element is reserved to distinguish between full/empty state. When using plain generic functions with smaller integer types, be aware of integer overflows. No care taken to prevent these.
proxy.golang.org
v1.0.1
about 1 year ago
2
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/nsf/ringbuffer
spec |
| License | MIT |
| Namespace | github.com/nsf |
| First Release | about 1 year ago |
| Last Synced | 8 days ago |
Repository
| Stars | 1 on GitHub |
| Forks | 0 on GitHub |