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, line 22
def self.[](*args)
  a = self.new
  args.each do |elem|
    a.push elem
  end
  a
end
new() click to toggle source

Creates a new object

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 31
def initialize
  @hash = {}
  #clear_cache
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, line 124
def +(other)
  unless other.is_a?(self.class) then
    raise TypeError, 'unsupported data type'
  end
  new_hash = @hash.merge(other.internal_data_hash)
  result = self.class.new
  result.internal_data_hash = new_hash
  result
end
<<(elem) click to toggle source

Same usage as Array#<<

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 168
def <<(elem)
  push_element(elem)
  self
end
==(other) click to toggle source

Same usage as Array#==

Calls superclass method
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 135
def ==(other)
  if r = super(other) then
    r
  elsif other.is_a?(self.class) then
    other.internal_data_hash == @hash
  else
    false
  end
end
[](*arg) click to toggle source

Same usage as Array#[]

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 103
def [](*arg)
  #$stderr.puts "SortedNumArray#[]"
  sorted_keys[*arg]
end
[]=(*arg) click to toggle source

Not implemented

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 109
def []=(*arg)
  raise NotImplementedError, 'SortedNumArray#[]= is not implemented.'
end
concat(ary) click to toggle source

Same usage as Array#concat

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 146
def concat(ary)
  ary.each { |elem| push_element(elem) }
  self
end
delete(elem) click to toggle source

Same usage as Array#delete

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 195
def delete(elem)
  #clear_cache
  @hash.delete(elem) ? elem : nil
end
each(&block) click to toggle source

Same usage as Array#each

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 114
def each(&block)
  sorted_keys.each(&block)
end
first() click to toggle source

Same usage as Array#first

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 179
def first
  sorted_keys.first
end
include?(elem) click to toggle source

Same usage as Array#include?

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 174
def include?(elem)
  @hash.has_key?(elem)
end
initialize_copy(other) click to toggle source

initialize copy

Calls superclass method
# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 37
def initialize_copy(other)
  super(other)
  @hash = @hash.dup
end
last() click to toggle source

Same usage as Array#last

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 184
def last
  sorted_keys.last
end
length()
Alias for: size
push(*args) click to toggle source

Same usage as Array#push

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 152
def push(*args)
  args.each do |elem|
    push_element(elem)
  end
  self
end
reverse_each(&block) click to toggle source

Same usage as Array#reverse_each

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 119
def reverse_each(&block)
  sorted_keys.reverse_each(&block)
end
size() click to toggle source

Same usage as Array#size

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 189
def size
  @hash.size
end
Also aliased as: length
sort!(&block) click to toggle source

Does nothing

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 201
def sort!(&block)
  # does nothing
  self
end
to_a() click to toggle source

Converts to an array

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 213
def to_a
  #sorted_keys.dup
  sorted_keys
end
uniq!() click to toggle source

Does nothing

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 207
def uniq!
  # does nothing
  self
end
unshift(*arg) click to toggle source

Same usage as Array#unshift

# File lib/bio/util/restriction_enzyme/sorted_num_array.rb, line 160
def unshift(*arg)
  arg.reverse_each do |elem|
    unshift_element(elem)
  end
  self
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, line 51
def internal_data_hash
  @hash
end
internal_data_hash=(h) click to toggle source

sets internal hash object

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