Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A simple Ruby implementation of a Circular Buffer

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 AUTHORS
Octocat-spinner-32 COPYING
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 cbuffer.gemspec
README.md

CBuffer

Overview

A circular buffer, cyclic buffer or ring buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. This structure lends itself easily to buffering data streams. This library impliments such a buffer.

Installation

gem install cbuffer

** Usage

require 'cbuffer'

a = CBuffer.new 5 => <CBuffer @size=5> 
a.put 1 => false 
a.put 2 => false 
a.put "Duncan" => false 
a.put 999 => false 
a.get => 1 
a.get => 2 
a.get => "Duncan" 
a.put "xxx" => false 
a.get => 999

Todo

  • threading support
  • fetch items by index
  • view onto items

Contributing

  • Fork the project
  • Send a pull request
  • Don't touch the .gemspec, I'll do that when I release a new version
Something went wrong with that request. Please try again.