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 22 22: def self.[](*args) 23: a = self.new 24: args.each do |elem| 25: a.push elem 26: end 27: a 28: end
Same usage as Array#+, but accepts only the same classes instance.
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 124 124: def +(other) 125: unless other.is_a?(self.class) then 126: raise TypeError, 'unsupported data type' 127: end 128: new_hash = @hash.merge(other.internal_data_hash) 129: result = self.class.new 130: result.internal_data_hash = new_hash 131: result 132: end
Same usage as Array#<<
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 168 168: def <<(elem) 169: push_element(elem) 170: self 171: end
Same usage as Array#==
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 135 135: def ==(other) 136: if r = super(other) then 137: r 138: elsif other.is_a?(self.class) then 139: other.internal_data_hash == @hash 140: else 141: false 142: end 143: end
Same usage as Array#[]
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 103 103: def [](*arg) 104: #$stderr.puts "SortedNumArray#[]" 105: sorted_keys[*arg] 106: end
Not implemented
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 109 109: def []=(*arg) 110: raise NotImplementedError, 'SortedNumArray#[]= is not implemented.' 111: end
Same usage as Array#concat
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 146 146: def concat(ary) 147: ary.each { |elem| push_element(elem) } 148: self 149: end
Same usage as Array#delete
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 195 195: def delete(elem) 196: #clear_cache 197: @hash.delete(elem) ? elem : nil 198: end
Same usage as Array#each
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 114 114: def each(&block) 115: sorted_keys.each(&block) 116: end
Same usage as Array#first
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 179 179: def first 180: sorted_keys.first 181: end
Same usage as Array#include?
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 174 174: def include?(elem) 175: @hash.has_key?(elem) 176: end
initialize copy
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 37 37: def initialize_copy(other) 38: super(other) 39: @hash = @hash.dup 40: end
Same usage as Array#last
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 184 184: def last 185: sorted_keys.last 186: end
Same usage as Array#push
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 152 152: def push(*args) 153: args.each do |elem| 154: push_element(elem) 155: end 156: self 157: end
Same usage as Array#reverse_each
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 119 119: def reverse_each(&block) 120: sorted_keys.reverse_each(&block) 121: end
Same usage as Array#size
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 189 189: def size 190: @hash.size 191: end
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 201 201: def sort!(&block) 202: # does nothing 203: self 204: end
Converts to an array
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 213 213: def to_a 214: #sorted_keys.dup 215: sorted_keys 216: end
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 207 207: def uniq! 208: # does nothing 209: self 210: end
Same usage as Array#unshift
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 160 160: def unshift(*arg) 161: arg.reverse_each do |elem| 162: unshift_element(elem) 163: end 164: self 165: end
gets internal hash object
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 51 51: def internal_data_hash 52: @hash 53: end