Module jls.util.Map

Represents a map.

Class Map

Map:new () Creates a new Map.
map:set (key, value) Adds or updates an entry with a specified key and a value.
map:delete (key) Deletes the entry with the specified key.
map:remove (key) Removes and returns the entry with the specified key.
map:get (key) Returns the value corresponding to the specified key.
map:has (key) Returns true if an entry exists for the specified key.
map:clear () Deletes all entries.
map:keys () Returns the keys.
map:values () Returns the values.
map:isEmpty () Returns true if the map is empty.
map:size () Returns the number of entries.
map:skeys ([comp]) Returns the keys, sorted.
map:spairs ([comp]) Returns an iterator sorted and suitable for the generic "for" loop.
map:add (...) Adds a new element to this map such as the key is also the value.
map:getTable () Returns the internal map table.
Map.assign (target, ...) Sets all key-values of the specified tables to the target table.


Class Map

A Map class.
Map:new ()
Creates a new Map.
map:set (key, value)
Adds or updates an entry with a specified key and a value.

Parameters:

  • key The key of the entry to set.
  • value The value of the entry to set.

Returns:

    jls.util.Map this map.
map:delete (key)
Deletes the entry with the specified key.

Parameters:

  • key The key of the entry to delete.

Returns:

    boolean true if an antry has been deleted.
map:remove (key)
Removes and returns the entry with the specified key.

Parameters:

  • key The key of the entry to remove.

Returns:

    the entry removed or nil.
map:get (key)
Returns the value corresponding to the specified key.

Parameters:

  • key The key of the entry to get.

Returns:

    the value or nil.
map:has (key)
Returns true if an entry exists for the specified key.

Parameters:

  • key The key of the entry to test.

Returns:

    boolean true if an entry exists.
map:clear ()
Deletes all entries.
map:keys ()
Returns the keys.

Returns:

    table the keys.
map:values ()
Returns the values.

Returns:

    table the values.
map:isEmpty ()
Returns true if the map is empty.

Returns:

    boolean true if the map is empty.
map:size ()
Returns the number of entries.

Returns:

    number the number of entries.
map:skeys ([comp])
Returns the keys, sorted.

Parameters:

  • comp function The comparison function. (optional)

Returns:

    table the keys.
map:spairs ([comp])
Returns an iterator sorted and suitable for the generic "for" loop.

Parameters:

  • comp function The comparison function. (optional)

Returns:

    an iterator.
map:add (...)
Adds a new element to this map such as the key is also the value. This method allows to use this map as a set.

Parameters:

  • ... Additional values to add.

Returns:

    jls.util.Map this map.
map:getTable ()
Returns the internal map table.

Returns:

    table the internal map table.
Map.assign (target, ...)
Sets all key-values of the specified tables to the target table.

Parameters:

  • target table The table to update.
  • ... table The tables to get key-values from.

Returns:

    table the target table.
generated by LDoc 1.4.6