Module pl.classx

extra classes: MultiMap, OrderedMap and Typed List.

Functions

MultiMap:set (key, val) add a new value to a key.
MultiMap:update (t) update a MultiMap using a table.
OrderedMap:iter () iterate over key-value pairs in order.
OrderedMap:keys () return the keys in order.
OrderedMap:set (key, val) set the key's value.
OrderedMap:sort (cmp) sort the keys.
OrderedMap:update (t) update an OrderedMap using a table.
OrderedMap:values () return the values in order.
TypedList:append (val) append a value to the list.
TypedList:extend (L) extend the list using another list.
TypedList:slice (i1, i2) return a slice of the list

Tables

TypedList construct a specific TypedList.


Functions

MultiMap:set (key, val)
add a new value to a key.

Parameters:

  • key: the key
  • val: the value
MultiMap:update (t)
update a MultiMap using a table.

Parameters:

  • t: either a Multimap or a map-like table.
OrderedMap:iter ()
iterate over key-value pairs in order.
OrderedMap:keys ()
return the keys in order. (Not a copy!)
OrderedMap:set (key, val)
set the key's value.

Parameters:

  • key: the key
  • val: the value
OrderedMap:sort (cmp)
sort the keys.

Parameters:

  • cmp:
OrderedMap:update (t)
update an OrderedMap using a table.

Parameters:

  • t: map-like table.
OrderedMap:values ()
return the values in order. this is relatively expensive.
TypedList:append (val)
append a value to the list. Will throw an error if the value is not of the correct type.

Parameters:

  • val: a value of the correct type.

Return value:

    the list
TypedList:extend (L)
extend the list using another list.

Parameters:

  • L: a list of the same type.

Return value:

    the list
TypedList:slice (i1, i2)
return a slice of the list

Parameters:

  • i1: start of slice
  • i2: end of slice

Return value:

    a new typed list

See also:

Tables

TypedList
construct a specific TypedList. For example, class.StringList(TypedList,'string')

Valid XHTML 1.0!