From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- Data/Libraries/Penlight/docs/classes/pl.Map.html | 454 +++++++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/classes/pl.Map.html (limited to 'Data/Libraries/Penlight/docs/classes/pl.Map.html') diff --git a/Data/Libraries/Penlight/docs/classes/pl.Map.html b/Data/Libraries/Penlight/docs/classes/pl.Map.html new file mode 100644 index 0000000..72b4b40 --- /dev/null +++ b/Data/Libraries/Penlight/docs/classes/pl.Map.html @@ -0,0 +1,454 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Class pl.Map

+

A Map class.

+

+ + + +

+> Map = require 'pl.Map'
+> m = Map{one=1,two=2}
+> m:update {three=3,four=4,two=20}
+> = m == M{one=1,two=20,three=3,four=4}
+true
+
+ +

Dependencies: pl.utils, pl.class, pl.tablex, pl.pretty

+

+ + +

Fields

+ + + + + + + + + +
pl.Map.keyslist of keys.
pl.Map.valueslist of values.
+

Methods

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
pl.Map:iter ()return an iterator over all key-value pairs.
pl.Map:items ()return a List of all key-value pairs, sorted by the keys.
pl.Map:setdefault (key, default)set a value in the map if it doesn't exist yet.
pl.Map:len ()size of map.
pl.Map:set (key, val)put a value into the map.
pl.Map:get (key)get a value from the map.
pl.Map:getvalues (keys)get a list of values indexed by a list of keys.
pl.Map:update (table)update the map using key/value pairs from another table.
+

Metamethods

+ + + + + + + + + +
pl.Map:__eq (m)equality between maps.
pl.Map:__tostring ()string representation of a map.
+ +
+
+ + +

Fields

+ +
+
+ + pl.Map.keys +
+
+ list of keys. + + + + + + + +
+
+ + pl.Map.values +
+
+ list of values. + + + + + + + +
+
+

Methods

+ +
+
+ + pl.Map:iter () +
+
+ return an iterator over all key-value pairs. + + + + + + + +
+
+ + pl.Map:items () +
+
+ return a List of all key-value pairs, sorted by the keys. + + + + + + + +
+
+ + pl.Map:setdefault (key, default) +
+
+ set a value in the map if it doesn't exist yet. + + +

Parameters:

+
    +
  • key + the key +
  • +
  • default + value to set +
  • +
+ +

Returns:

+
    + + the value stored in the map (existing value, or the new value) +
+ + + + +
+
+ + pl.Map:len () +
+
+ size of map. + note: this is a relatively expensive operation! + + + + + + + +
+
+ + pl.Map:set (key, val) +
+
+ put a value into the map. + This will remove the key if the value is nil + + +

Parameters:

+
    +
  • key + the key +
  • +
  • val + the value +
  • +
+ + + + + +
+
+ + pl.Map:get (key) +
+
+ get a value from the map. + + +

Parameters:

+
    +
  • key + the key +
  • +
+ +

Returns:

+
    + + the value, or nil if not found. +
+ + + + +
+
+ + pl.Map:getvalues (keys) +
+
+ get a list of values indexed by a list of keys. + + +

Parameters:

+
    +
  • keys + a list-like table of keys +
  • +
+ +

Returns:

+
    + + a new list +
+ + + + +
+
+ + pl.Map:update (table) +
+
+ update the map using key/value pairs from another table. + + +

Parameters:

+
    +
  • table + tab + + + +
  • +
+ + + + + +
+
+

Metamethods

+ +
+
+ + pl.Map:__eq (m) +
+
+ equality between maps. + + +

Parameters:

+
    +
  • m + Map + another map. +
  • +
+ + + + + +
+
+ + pl.Map:__tostring () +
+
+ string representation of a map. + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0