Class | Bio::RestrictionEnzyme::SortedNumArray
In: | lib/bio/util/restriction_enzyme/sorted_num_array.rb
Parent: | Object

a class to store sorted numerics.

Bio::RestrictionEnzyme internal use only. Please do not create the instance outside Bio::RestrictionEnzyme.

### Methods

+ << == [] [] []= concat delete each first include? initialize_copy internal_data_hash internal_data_hash= last length new push reverse_each size sort! to_a uniq! unshift

### Public Class methods

[](*args)

Same usage as Array.[]

[Source]

        # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 19
    19:     def self.[](*args)
    20:       a = self.new
    21:       args.each do |elem|
    22:         a.push elem
    23:       end
    24:       a
    25:     end

new()

Creates a new object

[Source]

        # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 28
    28:     def initialize
    29:       @hash = {}
    30:       #clear_cache
    31:     end

### Public Instance methods

+(other)

Same usage as Array#+, but accepts only the same classes instance.

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 121
    121:     def +(other)
    122:       unless other.is_a?(self.class) then
    123:         raise TypeError, 'unsupported data type'
    124:       end
    125:       new_hash = @hash.merge(other.internal_data_hash)
    126:       result = self.class.new
    127:       result.internal_data_hash = new_hash
    128:       result
    129:     end

<<(elem)

Same usage as Array#<<

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 165
    165:     def <<(elem)
    166:       push_element(elem)
    167:       self
    168:     end

==(other)

Same usage as Array#==

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 132
    132:     def ==(other)
    133:       if r = super(other) then
    134:         r
    135:       elsif other.is_a?(self.class) then
    136:         other.internal_data_hash == @hash
    137:       else
    138:         false
    139:       end
    140:     end

[](*arg)

Same usage as Array#[]

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 100
    100:     def [](*arg)
    101:       #$stderr.puts "SortedNumArray#[]"
    102:       sorted_keys[*arg]
    103:     end

[]=(*arg)

Not implemented

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 106
    106:     def []=(*arg)
    107:       raise NotImplementedError, 'SortedNumArray#[]= is not implemented.'
    108:     end

concat(ary)

Same usage as Array#concat

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 143
    143:     def concat(ary)
    144:       ary.each { |elem| push_element(elem) }
    145:       self
    146:     end

delete(elem)

Same usage as Array#delete

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 192
    192:     def delete(elem)
    193:       #clear_cache
    194:       @hash.delete(elem) ? elem : nil
    195:     end

each(&block)

Same usage as Array#each

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 111
    111:     def each(&block)
    112:       sorted_keys.each(&block)
    113:     end

first()

Same usage as Array#first

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 176
    176:     def first
    177:       sorted_keys.first
    178:     end

include?(elem)

Same usage as Array#include?

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 171
    171:     def include?(elem)
    172:       @hash.has_key?(elem)
    173:     end

initialize_copy(other)

initialize copy

[Source]

        # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 34
    34:     def initialize_copy(other)
    35:       super(other)
    36:       @hash = @hash.dup
    37:     end

last()

Same usage as Array#last

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 181
    181:     def last
    182:       sorted_keys.last
    183:     end

length()

Alias for size

push(*args)

Same usage as Array#push

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 149
    149:     def push(*args)
    150:       args.each do |elem|
    151:         push_element(elem)
    152:       end
    153:       self
    154:     end

reverse_each(&block)

Same usage as Array#reverse_each

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 116
    116:     def reverse_each(&block)
    117:       sorted_keys.reverse_each(&block)
    118:     end

size()

Same usage as Array#size

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 186
    186:     def size
    187:       @hash.size
    188:     end

sort!(&block)

Does nothing

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 198
    198:     def sort!(&block)
    199:       # does nothing
    200:       self
    201:     end

to_a()

Converts to an array

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 210
    210:     def to_a
    211:       #sorted_keys.dup
    212:       sorted_keys
    213:     end

uniq!()

Does nothing

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 204
    204:     def uniq!
    205:       # does nothing
    206:       self
    207:     end

unshift(*arg)

Same usage as Array#unshift

[Source]

         # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 157
    157:     def unshift(*arg)
    158:       arg.reverse_each do |elem|
    159:         unshift_element(elem)
    160:       end
    161:       self
    162:     end

### Protected Instance methods

internal_data_hash()

gets internal hash object

[Source]

        # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 48
    48:     def internal_data_hash
    49:       @hash
    50:     end

internal_data_hash=(h)

sets internal hash object

[Source]

        # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 40
    40:     def internal_data_hash=(h)
    41:       #clear_cache
    42:       @hash = h
    43:       self
    44:     end

[Validate]