local E={}function E.merge(...)local E={}for Y,O in pairs({...})do for Y,O in pairs(O)do E[Y]=O end end return E end function E.count(E)local Y=0 for E in pairs(E)do Y=Y+1 end return Y end function E.map(E,Y)local O={}for x,L in pairs(E)do O[x]=Y(L,x,E)end return O end function E.clone(E)local Y={}for E,O in pairs(E)do Y[E]=O end return Y end return E
local Dictionary = {}

--- Merges key/value pairs from multiple dictionaries into one 
-- @param ... Tuple of dictionaries to merge
function Dictionary.merge(...)
	local newDictionary = {}

	for _, dictionary in pairs({ ... }) do
		for key, value in pairs(dictionary) do
			newDictionary[key] = value
		end
	end

	return newDictionary
end

--- Counts the number of items in a dictionary by iterating over it
-- @param dictionary The dictionary to count
function Dictionary.count(dictionary)
	local count = 0

	for _ in pairs(dictionary) do
		count = count + 1
	end
	
	return count
end

--- Like Array.Map, however it keeps the key
-- @param dictionary Dictionary to map
-- @param callback(value,key,dictionary) Function called on every element
function Dictionary.map(dictionary, callback)
	local newDictionary = {}

	for key, value in pairs(dictionary) do
		newDictionary[key] = callback(value, key, dictionary)
	end

	return newDictionary
end

--- Creates a shallow copy of a dictionary
-- @param dictionary The dictionary to copy
function Dictionary.clone(dictionary)
	local newDictionary = {}

	for key, value in pairs(dictionary) do
		newDictionary[key] = value
	end

	return newDictionary
end

return Dictionary