Update word.rb
This commit is contained in:
parent
9e0eca64e8
commit
aae168fe13
@ -191,30 +191,30 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def insert(index, other)
|
def insert(index, other)
|
||||||
if index<0
|
if index<0
|
||||||
index = length+1+index
|
index = length+1+index
|
||||||
end
|
end
|
||||||
cpy = Word.new( length+other.length )
|
cpy = Word.new( length+other.length )
|
||||||
cpy_ind=0
|
cpy_ind=0
|
||||||
str_ind=0
|
str_ind=0
|
||||||
while ( str_ind<index )
|
while ( str_ind<index )
|
||||||
cpy.set_char(cpy_ind,get_char(str_ind))
|
cpy.set_char(cpy_ind,get_char(str_ind))
|
||||||
cpy_ind=cpy_ind+1
|
cpy_ind=cpy_ind+1
|
||||||
str_ind=str_ind+1
|
str_ind=str_ind+1
|
||||||
end
|
end
|
||||||
oth_ind=0
|
oth_ind=0
|
||||||
while ( oth_ind<other.length )
|
while ( oth_ind<other.length )
|
||||||
cpy.set_char(cpy_ind,other.get_char(oth_ind))
|
cpy.set_char(cpy_ind,other.get_char(oth_ind))
|
||||||
cpy_ind=cpy_ind+1
|
cpy_ind=cpy_ind+1
|
||||||
oth_ind=oth_ind+1
|
oth_ind=oth_ind+1
|
||||||
end
|
end
|
||||||
while ( str_ind<length )
|
while ( str_ind<length )
|
||||||
cpy.set_char(cpy_ind,get_char(str_ind))
|
cpy.set_char(cpy_ind,get_char(str_ind))
|
||||||
str_ind=str_ind+1
|
str_ind=str_ind+1
|
||||||
cpy_ind=cpy_ind+1
|
cpy_ind=cpy_ind+1
|
||||||
end
|
end
|
||||||
cpy
|
cpy
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def check_length
|
def check_length
|
||||||
|
Loading…
Reference in New Issue
Block a user