Module pl.OrderedMap

OrderedMap.

Functions

OrderedMap:update (t) update an OrderedMap using a table.
OrderedMap:set (key, val) set the key's value.
OrderedMap:keys () return the keys in order.
OrderedMap:values () return the values in order.
OrderedMap:sort (cmp) sort the keys.
OrderedMap:iter () iterate over key-value pairs in order.


Functions

OrderedMap:update (t)
update an OrderedMap using a table.
If the table is itself an OrderedMap, then its entries will be appended.
if it s a table of the form {{key1=val1},{key2=val2},...} these will be appended.
Otherwise, it is assumed to be a map-like table, and order of extra entries is arbitrary.

Parameters:

  • t: a table.
OrderedMap:set (key, val)
set the key's value. This key will be appended at the end of the map.
If the value is nil, then the key is removed.

Parameters:

  • key: the key
  • val: the value
OrderedMap:keys ()
return the keys in order. (Not a copy!)
OrderedMap:values ()
return the values in order. this is relatively expensive.
OrderedMap:sort (cmp)
sort the keys.

Parameters:

  • cmp:
OrderedMap:iter ()
iterate over key-value pairs in order.