class BinPacking::Score

Constants

MAX_INT

Attributes

score_1[R]
score_2[R]

Public Class Methods

new(score_1 = nil, score_2 = nil) click to toggle source
# File lib/bin_packing/score.rb, line 13
def initialize(score_1 = nil, score_2 = nil)
  @score_1 = score_1 || MAX_INT
  @score_2 = score_2 || MAX_INT
end
new_blank() click to toggle source
# File lib/bin_packing/score.rb, line 9
def self.new_blank
  new
end

Public Instance Methods

<=>(other) click to toggle source

Smaller number is greater (used by original algorithm).

# File lib/bin_packing/score.rb, line 19
def <=>(other)
  if self.score_1 > other.score_1 || (self.score_1 == other.score_1 && self.score_2 > other.score_2)
    -1
  elsif self.score_1 < other.score_1 || (self.score_1 == other.score_1 && self.score_2 < other.score_2)
    1
  else
    0
  end
end
assign(other) click to toggle source
# File lib/bin_packing/score.rb, line 29
def assign(other)
  @score_1 = other.score_1
  @score_2 = other.score_2
end
decrease_by(delta) click to toggle source
# File lib/bin_packing/score.rb, line 38
def decrease_by(delta)
  @score_1 += delta
  @score_2 += delta
end
is_blank?() click to toggle source
# File lib/bin_packing/score.rb, line 34
def is_blank?
  @score_1 == MAX_INT
end