--[[
file name . GameList.lua
author . Clark/陈泽丹
created . 8.13.2011
purpose . 双向队列
--]]
module("GameList", package.seeall)
--双向队列
function list_newList()
local first = 1
local last = 0
local list = {}
local listManager = {}
function listManager.pushFront(_tempObj)
first = first - 1
list[first] = _tempObj
end
function listManager.pushBack(_tempObj)
last = last + 1
list[last] = _tempObj
end
function listManager.temp_getFront()
if listManager.bool_isEmpty() then
return nil
else
local val = list[first]
return val
end
end
function listManager.temp_getBack()
if listManager.bool_isEmpty() then
return nil
else
local val = list[last]
return val
end
end
function listManager.popFront()
list[first] = nil
first = first + 1
end
function listManager.popBack()
list[last] = nil
last = last - 1
end
function listManager.clear()
while false == listManager.bool_isEmpty() do
listManager.popFront()
end
end
function listManager.bool_isEmpty()
if first > last then
first = 1
last = 0
return true
else
return false
end
end
function listManager.d_getSize()
if listManager.bool_isEmpty() then
return 0
else
return last - first + 1
end
end
return listManager
end