class Tabu

this class maintains a tabu list and kicks elements out if they are too old

Public Class Methods

new(size) click to toggle source
# File lib/rsearch/tabu.rb, line 4
def initialize(size)
  @hash = {}
  @max = size
end

Public Instance Methods

include?(elem) click to toggle source
# File lib/rsearch/tabu.rb, line 20
def include?(elem)
  !@hash[elem].nil?
end
insert(elem) click to toggle source

decrease longevity of all keys and insert new one

# File lib/rsearch/tabu.rb, line 10
def insert(elem)
  @hash.each_key do |key|
    @hash[key] -= 1
    if @hash[key] <= 0
      @hash.delete(key)
    end
  end
  @hash[elem] = @max
end