Method: TwoDMatrix#checkInputBounds

Defined in:
lib/csrmatrix.rb

#checkInputBounds(row, col) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/csrmatrix.rb', line 124

def checkInputBounds(row, col)
  # checks whether or not the index searched is within bounds 
  if row > @rows
    raise IndexOutOfRangeException.new, "Row index too large"
    return false
  elsif col > @columns
    raise IndexOutOfRangeException.new, "Column index too large"
    return false
  elsif row < 0
    raise IndexOutOfRangeException.new, "Row index too small"
    return false
  elsif col < 0
    raise IndexOutOfRangeException.new, "Column index too small"
    return false
  else
    return true
  end
end