Implementation of a Gap Buffer for Ruby MRI.
(c) 2010 Lourens Naud
How Gap Buffers work :
en.wikipedia.org/wiki/Gap_buffer www.lazyhacker.com/gapbuffer/gapbuffer.htm
This library works with Ruby 1.8 and 1.9 and exposes the following API :
gb = GapBuffer.new
gb.size #=> 20
gb.offset #=> 9
gb << "test"
gb.print #=> test_______________
gb.insert('b')
gb.offset #=> 5
gb.print #=> testb______________
gb.insert_at(6, 'u')
gb.print #=> testbu_____________
gb.previous #=> b
gb.next #=> u
gb.offset = 7
gb.put('f')
gb.print #=> testbuf____________
To run the test suite:
rake
Todo:
Better 1.9 compat
Look into moving off the C++ implementation
Work in progress, thanks for watching!