-- Compiled with roblox-ts v1.3.3
warn("This DoublyLinkedList class should not be used anymore! Switch to @rbxts/linked-lists")
local DoublyLinkedList
do
	DoublyLinkedList = setmetatable({}, {
		__tostring = function()
			return "DoublyLinkedList"
		end,
	})
	DoublyLinkedList.__index = DoublyLinkedList
	function DoublyLinkedList.new(...)
		local self = setmetatable({}, DoublyLinkedList)
		return self:constructor(...) or self
	end
	function DoublyLinkedList:constructor(values)
		if values ~= nil and #values > 0 then
			self.head = {
				value = values[1],
			}
			local lastNewNode = self.head
			do
				local i = 1
				local _shouldIncrement = false
				while true do
					if _shouldIncrement then
						i += 1
					else
						_shouldIncrement = true
					end
					if not (i < #values) then
						break
					end
					local node = {
						previousNode = lastNewNode,
						value = values[i + 1],
					}
					lastNewNode.nextNode = node
					lastNewNode = node
				end
			end
			self.currentSize = #values
			self.tail = lastNewNode
		else
			self.currentSize = 0
		end
	end
	function DoublyLinkedList:clear()
		self.head = nil
		self.tail = nil
	end
	function DoublyLinkedList:getHeadNode()
		return self.head
	end
	function DoublyLinkedList:getHeadValue()
		if self.head ~= nil then
			return self.head.value
		end
	end
	function DoublyLinkedList:getTailNode()
		return self.tail
	end
	function DoublyLinkedList:getTailValue()
		if self.tail ~= nil then
			return self.tail.value
		end
	end
	function DoublyLinkedList:isEmpty()
		return self.head == nil
	end
	function DoublyLinkedList:popHeadValue()
		if self.head ~= nil then
			local currentHead = self.head
			if self.head.nextNode ~= nil then
				self.head = self.head.nextNode
			else
				self.head = nil
				self.tail = nil
			end
			self.currentSize -= 1
			return currentHead.value
		end
	end
	function DoublyLinkedList:popTailValue()
		if self.tail ~= nil then
			local currentTail = self.tail
			if self.tail.previousNode ~= nil then
				self.tail = self.tail.previousNode
			else
				self.head = nil
				self.tail = nil
			end
			self.currentSize -= 1
			return currentTail.value
		end
	end
	function DoublyLinkedList:pushToHead(value)
		local node = {
			value = value,
		}
		if self.head ~= nil then
			node.nextNode = self.head
			self.head.previousNode = node
			self.head = node
		else
			self.head = node
			self.tail = node
		end
		self.currentSize += 1
	end
	function DoublyLinkedList:pushToTail(value)
		local node = {
			value = value,
		}
		if self.tail ~= nil then
			node.previousNode = self.tail
			self.tail.nextNode = node
			self.tail = node
		else
			self.head = node
			self.tail = node
		end
		self.currentSize += 1
	end
	function DoublyLinkedList:pushListToHead(otherList)
		if otherList.head == nil or otherList.tail == nil then
			return nil
		end
		if self.head ~= nil then
			self.head.previousNode = otherList.tail
			otherList.tail.nextNode = self.head
			self.head = otherList.head
		else
			self.head = otherList.head
			self.tail = otherList.tail
		end
		self.currentSize += otherList:size()
	end
	function DoublyLinkedList:pushListToTail(otherList)
		if otherList.head == nil or otherList.tail == nil then
			return nil
		end
		if self.tail ~= nil then
			self.tail.nextNode = otherList.head
			otherList.head.previousNode = self.tail
			self.tail = otherList.tail
		else
			self.head = otherList.head
			self.tail = otherList.tail
		end
		self.currentSize += otherList:size()
	end
	function DoublyLinkedList:size()
		return self.currentSize
	end
end
return {
	DoublyLinkedList = DoublyLinkedList,
}
