Class: MiHash

Inherits:
Object
  • Object
show all
Defined in:
lib/matrc/mihash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, c) ⇒ MiHash

Returns a new instance of MiHash.



5
6
7
# File 'lib/matrc/mihash.rb', line 5

def initialize(r,c)
  @r, @c = r, c
end

Instance Attribute Details

#cObject

Returns the value of attribute c.



3
4
5
# File 'lib/matrc/mihash.rb', line 3

def c
  @c
end

#rObject

Returns the value of attribute r.



3
4
5
# File 'lib/matrc/mihash.rb', line 3

def r
  @r
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
20
21
# File 'lib/matrc/mihash.rb', line 17

def ==(other)
 self.class === other and
   other.c == @c and
   other.r == @r
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/matrc/mihash.rb', line 9

def eql?(other)
  (@r == other.r) && (@c == other.c)
end

#hashObject



13
14
15
# File 'lib/matrc/mihash.rb', line 13

def hash 
  @r.hash ^ @c.hash
end