Game Development Reference
In-Depth Information
currNode.next = _node
return
end
function _lists:delete(theVal)
if type(theVal) == "table" then
print("Cannot remove a table value from the list")
return
end
local currNode = self
if(self.value == theVal) then
local temp = self.next
if temp ~= nil then
self.value = temp.value
self.next = temp.next
else
self.value = nil
self.next = nil
end
return
end
lastVisited = currNode
while currNode ~= nil do
if currNode.value == theVal then
lastVisited.next = currNode.next
currNode = nil
return
end
lastVisited = currNode
currNode = currNode.next
end
return
end
function _lists:displayList()
local currNode = self
if(self.value == nil) then
print ("No entries in this list")
return
end
while currNode ~= nil do
print(currNode.value)
currNode = currNode.next
end
end
Search WWH ::




Custom Search