class DlinkedList
Clase DlinkedList
almacena los datos en una lista
Attributes
head[R]
tail[R]
Public Class Methods
new()
click to toggle source
# File lib/DlinkedList.rb, line 17 def initialize() @head = @tail = nil end
Public Instance Methods
each() { |value| ... }
click to toggle source
insertHead(value)
click to toggle source
insertTail(value)
click to toggle source
ordenarEach()
click to toggle source
# File lib/DlinkedList.rb, line 210 def ordenarEach arrayOrd = [] each do |nodo| if arrayOrd.empty? arrayOrd.push(nodo) else indice = 0 while indice < arrayOrd.length if nodo <= arrayOrd[indice] arrayOrd.insert(indice, nodo) break elsif indice == arrayOrd.length-1 arrayOrd.insert(indice+1, nodo) break end indice+=1 end end end return arrayOrd end
ordenarFor()
click to toggle source
# File lib/DlinkedList.rb, line 188 def ordenarFor arrayOrd = [] for nodo in self if arrayOrd.empty? arrayOrd.push(nodo) else indice = 0 while indice < arrayOrd.length if nodo <= arrayOrd[indice] arrayOrd.insert(indice, nodo) break elsif indice == arrayOrd.length-1 arrayOrd.insert(indice+1, nodo) break end indice+=1 end end end return arrayOrd end
popHead()
click to toggle source
popTail()
click to toggle source
removeAll()
click to toggle source
Extrae por la cabeza de la lista todos los nodos que quedan en la lista si no esta vacia
Parameters:¶ ↑
No recibe nada
Returns:¶ ↑
Retorna los nodos extraidos
# File lib/DlinkedList.rb, line 140 def removeAll unless @head.nil? while @head != nil aux = @head.next self.popHead @head = aux aux end end end