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.
Same usage as Array.[]
# 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
Same usage as Array#+, but accepts only the same classes instance.
# 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
Same usage as Array#<<
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 165 165: def <<(elem) 166: push_element(elem) 167: self 168: end
Same usage as Array#==
# 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
Same usage as Array#[]
# 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
Not implemented
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 106 106: def []=(*arg) 107: raise NotImplementedError, 'SortedNumArray#[]= is not implemented.' 108: end
Same usage as Array#concat
# 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
Same usage as Array#delete
# 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
Same usage as Array#each
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 111 111: def each(&block) 112: sorted_keys.each(&block) 113: end
Same usage as Array#first
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 176 176: def first 177: sorted_keys.first 178: end
Same usage as Array#include?
# 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
# 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
Same usage as Array#last
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 181 181: def last 182: sorted_keys.last 183: end
Same usage as Array#push
# 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
Same usage as Array#reverse_each
# 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
Same usage as Array#size
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 186 186: def size 187: @hash.size 188: end
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 198 198: def sort!(&block) 199: # does nothing 200: self 201: end
Converts to an array
# 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
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 204 204: def uniq! 205: # does nothing 206: self 207: end
Same usage as Array#unshift
# 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
gets internal hash object
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 48 48: def internal_data_hash 49: @hash 50: end