Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MarcAzar/BipBuffer
A Nim implementation of Simon Cooke's Bib Buffer
https://github.com/MarcAzar/BipBuffer
Last synced: 3 months ago
JSON representation
A Nim implementation of Simon Cooke's Bib Buffer
- Host: GitHub
- URL: https://github.com/MarcAzar/BipBuffer
- Owner: MarcAzar
- License: mit
- Created: 2019-02-24T09:46:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-04T14:53:28.000Z (over 5 years ago)
- Last Synced: 2024-05-18T15:33:14.888Z (6 months ago)
- Language: Nim
- Homepage: https://marcazar.github.io/BipBuffer/
- Size: 61.5 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nim - BipBuffer - A Nim implementation of Simon Cooke's Bib Buffer (Data / Data Structures)
README
# BipBuffer
A Nim implementation of Simon Cooke's Bip Buffer. A Bi-partite buffer is similar to a circular buffer, but where data is inserted in two revolving regions. This allows reads to return contiguous blocks of memory, even if they span a region that would normally include a wrap-around in a circular buffer. It's especially useful for APIs requiring blocks of contiguous memory, eliminating the need to copy data into an interim buffer before use.## Example Usage
```
import bipbuffervar buffer = newBipBuffer[int](4) # Create buffer wuth capacity of 4 int items
block:
var reserved = buffer.reserve(4) # Reserve 4 slots for insert on buffer
reserved[0] = 7 # Assign data to buffer slots
reserved[1] = 22
reserved[2] = 218
reserved[3] = 56buffer.commit(4) # Commit reserved data into an available region on buffer
block:
var bloc = buffer.read # Get stored data in a contiguous block
assert bloc[0] == 7
assert bloc[1] == 22
assert bloc[2] == 218
assert bloc[3] = 56buffer.decommit(2) # Mark first two parts of the block as free
block:
var bloc = buffer.read # The block should now contain only the last two values
assert bloc[0] == 218
assert bloc[1] == 56
```
## Installation
Install Nim for Windows or Unix by following the instructions in , or preferably by installing choosenimOnce ```choosenim``` is installed you can ```nimble install bipbuffer``` to pull the latest bipbuffer release and all its dependencies
## Documentation
Documentation can be found here