Module: Quicopt::Positions Private

Defined in:
lib/quicopt/structured.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Position checks shared by Permutation and LookupTable.

Class Method Summary collapse

Class Method Details

.check(k, extent, what, owner) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

k, checked to be an Integer in 0...extent.

Raises:

  • (TypeError) —

    if k is not an Integer

  • (ArgumentError) —

    if it is out of range



37
38
39
40
41
42
43
44
# File 'lib/quicopt/structured.rb', line 37

def check(k, extent, what, owner)
  raise TypeError, "#{owner}: a #{what} is a whole number, got #{k.inspect}" unless k.is_a?(Integer)
  unless k >= 0 && k < extent
    raise ArgumentError, "#{owner} has #{what}s 0 to #{extent - 1}, got #{k}"
  end

  k
end