Minor changes

This commit is contained in:
Vitor Oliveira 2021-02-13 10:19:12 -08:00
parent 58b9b599fa
commit f73c8ff2c2

View file

@ -59,7 +59,7 @@ class CircularList
puts(STDOUT.flush) puts(STDOUT.flush)
end end
def delete_tail def delete_head
return if @head.nil? return if @head.nil?
if @head.next != @head if @head.next != @head
@ -74,7 +74,9 @@ class CircularList
end end
def delete_tail def delete_tail
if !@head.nil? && (@head.next != @head) return if @head.nil?
if @head.next != @head
tempNode = @head tempNode = @head
tempNode = tempNode.next while tempNode.next.next != @head tempNode = tempNode.next while tempNode.next.next != @head
tempNode.next = @head tempNode.next = @head
@ -103,5 +105,5 @@ obj.print_list
obj.delete_tail obj.delete_tail
obj.print_list obj.print_list
obj.delete_tail obj.delete_head
obj.print_list obj.print_list