omdl  v0.6.1
OpenSCAD Mechanical Design Library

Map data type operations. More...

+ Collaboration diagram for Maps:

Files

file  datatypes_map.scad
 Map data type operations.
 

Functions

function get_map_i (m, k)
 Return the index of a map key. More...
 
function map_exists (m, k)
 Test if a key exists. More...
 
function get_map_v (m, k)
 Get the map value associated with a key. More...
 
function get_map_kl (m)
 Get a list of all map keys. More...
 
function get_map_vl (m)
 Get a list of all map values. More...
 
function get_map_size (m)
 Get the number of map entries. More...
 
module map_check (m, verbose=false)
 Perform some basic validation/checks on a map. More...
 
module map_dump (m, sort=true, number=true, p=3)
 Dump each map entry to the console. More...
 

Detailed Description

Map data type operations.

Example

Result

ECHO: "[ INFO ] map_check(); begin map check"
ECHO: "[ INFO ] map_check(); checking map format and keys."
ECHO: "[ INFO ] map_check(); map size: 6 entries."
ECHO: "[ INFO ] map_check(); end map check"
ECHO: "is part0 = false"
ECHO: "is part1 = true"
ECHO: c = [10, 11, 13]
ECHO: n = "part1", p = "screw10", l = [10, 11, 13]
ECHO: n = "part2", p = "screw12", l = [20, 21, 30]
ECHO: n = "part3", p = "screw10", l = [10, 10, -12]
ECHO: "003: 'config' = '["top", "front", "rear"]'"
ECHO: "000: 'part1' = '["screw10", [10, 11, 13]]'"
ECHO: "001: 'part2' = '["screw12", [20, 21, 30]]'"
ECHO: "002: 'part3' = '["screw10", [10, 10, -12]]'"
ECHO: "005: 'runid' = '10'"
ECHO: "004: 'version' = '[21, 5, 0]'"
ECHO: "map size: 6 entries."

Function Documentation

function get_map_i ( ,
 
)

Return the index of a map key.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
k<string> A map key.
Returns
<integer> The index of the map entry if it exists. Returns undef if key is not a string or does not exists.

+ Here is the caller graph for this function:

function get_map_kl ( )

Get a list of all map keys.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
Returns
<string-list-N> A list of key strings for all N map entries.

+ Here is the caller graph for this function:

function get_map_size ( )

Get the number of map entries.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
Returns
<integer> The number of map entries.

+ Here is the caller graph for this function:

function get_map_v ( ,
 
)

Get the map value associated with a key.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
k<string> A map key.
Returns
<value> The value associated with key. Returns undef if key does not exists.

+ Here is the caller graph for this function:

function get_map_vl ( )

Get a list of all map values.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
Returns
<list-N> A list of values for all N map entries.
module map_check ( ,
verbose  = false 
)

Perform some basic validation/checks on a map.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
verbose<boolean> Be verbose during check.

Check that: (1) each entry has key-value 2-tuple, (2) each key is a string, and (3) key identifiers are unique.

Definition at line 147 of file datatypes_map.scad.

+ Here is the call graph for this function:

module map_dump ( ,
sort  = true,
number  = true,
= 3 
)

Dump each map entry to the console.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
sort<boolean> Sort the output by key.
number<boolean> Output index number.
p<integer> Number of places for zero-padded numbering.

Definition at line 221 of file datatypes_map.scad.

+ Here is the call graph for this function:

function map_exists ( ,
 
)

Test if a key exists.

Parameters
m<matrix-2xN> A list of N key-value map pairs.
k<string> A map key.
Returns
<boolean> true when the key exists and false otherwise.