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

Same usage as Array.[]

[Source]

    # 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

Creates a new object

[Source]

    # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 31
31:     def initialize
32:       @hash = {}
33:       #clear_cache
34:     end

Public Instance methods

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

[Source]

     # 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#<<

[Source]

     # 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#==

[Source]

     # 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#[]

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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?

[Source]

     # 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

[Source]

    # 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

[Source]

     # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 184
184:     def last
185:       sorted_keys.last
186:     end
length()

Alias for size

Same usage as Array#push

[Source]

     # 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

[Source]

     # 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

[Source]

     # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 189
189:     def size
190:       @hash.size
191:     end

Does nothing

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

[Source]

     # 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

Protected Instance methods

gets internal hash object

[Source]

    # File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 51
51:     def internal_data_hash
52:       @hash
53:     end

sets internal hash object

[Source]

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

[Validate]