CValueSet Class Description
The CValueSet class manages a collection (or set) of keyed values. Each set member consists of a string key and a value that may one of the following types: "number", "integer", "string", or "boolean" true/false. All values in the set have the same type. The values may be retrieved using key (a string) or by their index in the collection. Thus, each value must have a unique key. Note that the object can also be created using new_valueset.
For example, here is a CValueSet object with 3 members that are a string key and number value:
|
|
|
|
|
|
These (key, value) pairs may be explicitly defined as a 2 element table for each member:
|
-- create a master table, "member" |
|
|
-- create a table for key-value pairs |
|
|
-- assign member[1] as a key-value pair |
|
|
-- create a table for key-value pairs |
|
|
-- assign member[2] as a key-value pair |
|
|
-- create a table for key-value pairs |
|
|
-- assign member[3] as a key-value pair |
Here is a CValueSet object with 3 members that uses string values:
|
|
|
|
|
|
Construction |
Object = new_valueset() Object = CValueSet:new() |
Destruction |
Object:delete() |
This function is normally used to create a new CValueSet object as an alternative to the class-based new method.
Global function that creates a new CValueSet object. |
Creates a new instance of the CValueSet class |
|
Deletes the instance of the CValueSet object. |
Adds a (string key, value) pair at the end of the set. |
|
Copies another CValueSet or a 1-dimensional array with values that are numbers. of keyed values to this CValueSet |
|
Returns the number of members in the set. |
|
Removes all set members |
|
Returns the value for the specified key. |
|
Returns both the key and value at the specified index. |
|
Returns the key at the specified index. |
|
Returns the value type as "number", "integer", "string", or "boolean". |
|
Returns the value at the specified index. |
|
Inserts a (string key, value) pair at the specified set index. |
|
Lists the set contents of the CValueSet in a Mira Text window. |
|
Removes the (string key, value) pair at the specified set index. |
|
Removes the (string key, value) pair by matching its key. |
|
Sets the value at the specified (existing) key. |
|
Sets the value at the specified (existing) index. |
|
Sets the value type for the CValueSet. This empties the set so that new values can be added with the new value type. |
|
Sorts the set into ascending order according to its values. |
|
Sorts the set into ascending order according to its keys. |
|
Creates a lua table of (string key, value) pairs. |
CArray, Table and Array Functions
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.