class Bio::RestrictionEnzyme::SortedNumArray
a class to store sorted numerics.
Bio::RestrictionEnzyme
internal use only. Please do not create the instance outside Bio::RestrictionEnzyme
.
Public Class Methods
[](*args)
click to toggle source
Same usage as Array.[]
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 22 def self.[](*args) 23 a = self.new 24 args.each do |elem| 25 a.push elem 26 end 27 a 28 end
new()
click to toggle source
Creates a new object
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 31 def initialize 32 @hash = {} 33 #clear_cache 34 end
Public Instance Methods
+(other)
click to toggle source
Same usage as Array#+, but accepts only the same classes instance.
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 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
<<(elem)
click to toggle source
Same usage as Array#<<
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 168 def <<(elem) 169 push_element(elem) 170 self 171 end
==(other)
click to toggle source
Same usage as Array#==
Calls superclass method
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 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
[](*arg)
click to toggle source
Same usage as Array#[]
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 103 def [](*arg) 104 #$stderr.puts "SortedNumArray#[]" 105 sorted_keys[*arg] 106 end
[]=(*arg)
click to toggle source
Not implemented
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 109 def []=(*arg) 110 raise NotImplementedError, 'SortedNumArray#[]= is not implemented.' 111 end
concat(ary)
click to toggle source
Same usage as Array#concat
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 146 def concat(ary) 147 ary.each { |elem| push_element(elem) } 148 self 149 end
delete(elem)
click to toggle source
Same usage as Array#delete
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 195 def delete(elem) 196 #clear_cache 197 @hash.delete(elem) ? elem : nil 198 end
each(&block)
click to toggle source
Same usage as Array#each
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 114 def each(&block) 115 sorted_keys.each(&block) 116 end
first()
click to toggle source
Same usage as Array#first
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 179 def first 180 sorted_keys.first 181 end
include?(elem)
click to toggle source
Same usage as Array#include?
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 174 def include?(elem) 175 @hash.has_key?(elem) 176 end
initialize_copy(other)
click to toggle source
initialize copy
Calls superclass method
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 37 def initialize_copy(other) 38 super(other) 39 @hash = @hash.dup 40 end
last()
click to toggle source
Same usage as Array#last
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 184 def last 185 sorted_keys.last 186 end
push(*args)
click to toggle source
Same usage as Array#push
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 152 def push(*args) 153 args.each do |elem| 154 push_element(elem) 155 end 156 self 157 end
reverse_each(&block)
click to toggle source
Same usage as Array#reverse_each
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 119 def reverse_each(&block) 120 sorted_keys.reverse_each(&block) 121 end
size()
click to toggle source
Same usage as Array#size
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 189 def size 190 @hash.size 191 end
Also aliased as: length
sort!(&block)
click to toggle source
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 201 def sort!(&block) 202 # does nothing 203 self 204 end
to_a()
click to toggle source
Converts to an array
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 213 def to_a 214 #sorted_keys.dup 215 sorted_keys 216 end
uniq!()
click to toggle source
Does nothing
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 207 def uniq! 208 # does nothing 209 self 210 end
unshift(*arg)
click to toggle source
Same usage as Array#unshift
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 160 def unshift(*arg) 161 arg.reverse_each do |elem| 162 unshift_element(elem) 163 end 164 self 165 end
Protected Instance Methods
internal_data_hash()
click to toggle source
gets internal hash object
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 51 def internal_data_hash 52 @hash 53 end
internal_data_hash=(h)
click to toggle source
sets internal hash object
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb 43 def internal_data_hash=(h) 44 #clear_cache 45 @hash = h 46 self 47 end