class Reline::KillRing::RingBuffer
Attributes
head[R]
size[R]
Public Class Methods
new(max = 1024)
click to toggle source
# File reline/kill_ring.rb, line 23 def initialize(max = 1024) @max = max @size = 0 @head = nil # reading head of ring-shaped tape end
Public Instance Methods
<<(point)
click to toggle source
# File reline/kill_ring.rb, line 29 def <<(point) if @size.zero? @head = point @head.backward = @head @head.forward = @head @size = 1 elsif @size >= @max tail = @head.forward new_tail = tail.forward @head.forward = point point.backward = @head new_tail.backward = point point.forward = new_tail @head = point else tail = @head.forward @head.forward = point point.backward = @head tail.backward = point point.forward = tail @head = point @size += 1 end end
empty?()
click to toggle source
# File reline/kill_ring.rb, line 54 def empty? @size.zero? end