Parent

Methods

Array

Ruby class: Array

Public Instance Methods

eql_eps(array, epsilon) click to toggle source
array

another array

epsilon

threshold accuracy

returns

true iff the arrays are equal, with a margin stablished by epsilon

    # File lib/data-structures.rb, line 7
 7:         def eql_eps(array, epsilon)

 8:                 if array.length != self.length

 9:                         return false

10:                 end

11:                 i = 0

12:                 result = true

13:                 while i < self.length && result

14:                         a = self[i]

15:                         b = array[i]

16:                         dif = a - b

17:                         if dif < 0

18:                                 dif = 1*dif

19:                         end

20:                         result = (dif < epsilon)

21:                         i+=1

22:                 end

23:                 return result         

24:         end
shuffle() click to toggle source
returns

the array shuffled

    # File lib/data-structures.rb, line 27
27:         def shuffle    

28:                 size.downto(1) { |n| push delete_at(rand(n)) }

29:                 self

30:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.