class Sequence::Reversed

This class can be used to reverse the direction of operations on a given sequence. It has a separate position, independant of the original sequence's.

Public Class Methods

new(sequence,pos=0) click to toggle source
# File lib/sequence/reversed.rb, line 15
def new(sequence,pos=0)
  if Circular===sequence
    Circular.new(new__no_circular(sequence.data,pos))
  else
    new__no_circular(sequence,pos)
  end
end
Also aliased as: new__no_circular
new(sequence,pos=0) click to toggle source
# File lib/sequence/reversed.rb, line 25
def initialize(sequence,pos=0)
    @seq = sequence
    @pos=pos
    @size=sequence.size
    extend @seq.like
    
    @seq.on_change_notify self
end
new__no_circular(sequence,pos=0)
Alias for: new

Public Instance Methods

change_notification(cu,first,oldsize,newsize) click to toggle source
# File lib/sequence/reversed.rb, line 38
    def change_notification(cu,first,oldsize,newsize)
#      Process.kill("INT",0)
      assert cu==@seq
#      @pos =translate_pos cu._adjust_pos_on_change(translate_pos(pos), first,oldsize,newsize)
      first=translate_pos(first+oldsize)
      @pos =_adjust_pos_on_change((pos), first,oldsize,newsize)
      @size+=newsize-oldsize
      assert @size==@seq.size
      notify_change(self, first,oldsize,newsize)
    end
translate_pos(pos) click to toggle source
# File lib/sequence/reversed.rb, line 34
def translate_pos(pos)
  @size-pos
end