Skip to content

Commit

Permalink
Documentation of Map.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaurens committed May 31, 2024
1 parent 767e9ba commit cb220ba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/pl/Map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ local function makelist(t)
return setmetatable(t, require('pl.List'))
end

--- list of keys.
--- return a List of all keys.
-- @class function
-- @name Map:keys
Map.keys = tablex.keys

--- list of values.
--- return a List of all values.
-- @class function
-- @name Map:keys
Map.values = tablex.values

--- return an iterator over all key-value pairs.
function Map:iter ()
return pairs(self)
end

--- return a List of all key-value pairs, sorted by the keys.
--- return a List of all key-value pairs, sorted by the keys in ascending order.
function Map:items()
local ls = makelist(tablex.pairmap (function (k,v) return makelist {k,v} end, self))
ls:sort(function(t1,t2) return t1[1] < t2[1] end)
Expand Down

0 comments on commit cb220ba

Please sign in to comment.