YCPBuiltinMap.cc File Reference

#include "ycp/YCPBuiltinMap.h"
#include "ycp/YCPMap.h"
#include "ycp/YCPSymbol.h"
#include "ycp/YCPBoolean.h"
#include "ycp/YCPInteger.h"
#include "ycp/YCPCode.h"
#include "ycp/YCPVoid.h"
#include "ycp/StaticDeclaration.h"
#include "ycp/y2log.h"

Functions

static YCPValue m_haskey (const YCPMap &map, const YCPValue &value)
 Check if map has a certain key.
static YCPValue m_filter (const YCPSymbol &key, const YCPSymbol &value, const YCPMap &map, const YCPCode &expr)
 Filter a Map For each key/value pair of the map MAP the expression EXPR is evaluated in a new context, where the variable KEY is assigned to the key and VALUE to the value of the pair. If the expression evaluates to true, the key/value pair is appended to the returned map.
static YCPValue m_mapmap (const YCPSymbol &key, const YCPSymbol &value, const YCPMap &map, const YCPCode &expr)
 Maps an operation onto all key/value pairs of a map.
static YCPValue m_maplist (const YCPSymbol &key, const YCPSymbol &value, const YCPMap &map, const YCPCode &expr)
 Maps an operation onto all elements key/value and create a list Maps an operation onto all elements key/value pairs of a map and thus creates a list.
static YCPValue m_unionmap (const YCPMap &map1, const YCPMap &map2)
 Union of 2 maps Interprets two maps as sets and returns a new map that has all elements of the first map MAP1and all of the second map MAP2. If elements have identical keys, values from MAP2 overwrite elements from MAP1.
static YCPValue m_addmap (const YCPMap &map, const YCPValue &key, const YCPValue &value)
 Add a key/value pair to a map.
static YCPValue m_changemap (YCPMap &map, const YCPValue &key, const YCPValue &value)
 Change element pair in a map DO NOT use this yet. It's for a special requst, not for common use!!!
static YCPValue m_size (const YCPValue &map)
 Size of a map.
static YCPValue m_foreach (const YCPValue &key, const YCPValue &val, const YCPMap &map, const YCPCode &expr)
 Process the content of a map For each key:value pair of the map MAP the expression EXPR is executed in a new context, where the variables KEY is bound to the key and VALUE is bound to the value. The return value of the last execution of exp is the value of the foreach construct.
static YCPValue m_tomap (const YCPValue &v)
 Converts a value to a map.
static YCPValue m_remove (const YCPMap &map, const YCPValue &key)
 Remove key/value pair from a map.

Variables

StaticDeclaration static_declarations

Function Documentation

static YCPValue m_addmap const YCPMap map,
const YCPValue key,
const YCPValue value
[static]
 

Add a key/value pair to a map.

add

Adds the key/value pair k : v to the map MAP and returns the newly Created map. If the key KEY exists in KEY, the old key/value pair is replaced with the new one. Functionality partly replaced with syntax: map map m = $["a":1]; m["b"] = 2; -> $["a":1, "b":2]

Parameters:
map MAP
any KEY
any VALUE
Returns:
map
add ($["a": 17, "b": 11], "c", 2) -> $["a":17, "b":11, "c":2] add ($["a": 17, "b": 11], "b", 2) -> $["a":17, "b":2]

static YCPValue m_changemap YCPMap map,
const YCPValue key,
const YCPValue value
[static]
 

Change element pair in a map DO NOT use this yet. It's for a special requst, not for common use!!!

change

Adds the key/value pair KEY : VALUE to the map MAP and returns the map. MAP is modified. If the key KEY exists in KEY, the old key/value pair is replaced with the new one.

Parameters:
map MAP
any KEY
any VALUE
change ($[.a: 17, .b: 11], .b, nil) -> $[.a:17, .b:nil].

static YCPValue m_filter const YCPSymbol key,
const YCPSymbol value,
const YCPMap map,
const YCPCode expr
[static]
 

Filter a Map For each key/value pair of the map MAP the expression EXPR is evaluated in a new context, where the variable KEY is assigned to the key and VALUE to the value of the pair. If the expression evaluates to true, the key/value pair is appended to the returned map.

filter

Parameters:
any KEY
any VALUE
map MAP
blocl EXPR
Returns:
map filter (`k, `v, $[1:"a", 2:"b", 3:3, 5:5], { return (k == v); }) -> $[3:3, 5:5]

static YCPValue m_foreach const YCPValue key,
const YCPValue val,
const YCPMap map,
const YCPCode expr
[static]
 

Process the content of a map For each key:value pair of the map MAP the expression EXPR is executed in a new context, where the variables KEY is bound to the key and VALUE is bound to the value. The return value of the last execution of exp is the value of the foreach construct.

foreach

Parameters:
any KEY
any VALUE
map MAP
any EXPR
Returns:
map
foreach (integer k, integer v, $[1:1,2:4,3:9], { y2debug("v = %1", v); return v; }) -> 9

static YCPValue m_haskey const YCPMap map,
const YCPValue value
[static]
 

Check if map has a certain key.

haskey

Determines whether the map MAP contains a pair with the key KEY. Returns true if this is true.

Parameters:
map MAP
any KEY
Returns:
boolean
haskey($["a":1, "b":2], "a") -> true haskey($["a":1, "b":2], "c") -> false

static YCPValue m_maplist const YCPSymbol key,
const YCPSymbol value,
const YCPMap map,
const YCPCode expr
[static]
 

Maps an operation onto all elements key/value and create a list Maps an operation onto all elements key/value pairs of a map and thus creates a list.

maplist

For each key/value pair of the map MAP the expression e is evaluated in a new context, where the variable KEY is assigned to the key and VALUE to the value of the pair. The result is the list of those evaluations.

Parameters:
any KEY
any VALUE
map MAP
block EXPR
Returns:
list
maplist (`k, `v, $[1:"a", 2:"b"], { return [k+10, v+"x"]; }) -> [ [11, "ax"], [ 12, "bx" ] ]

static YCPValue m_mapmap const YCPSymbol key,
const YCPSymbol value,
const YCPMap map,
const YCPCode expr
[static]
 

Maps an operation onto all key/value pairs of a map.

mapmap

Maps an operation onto all key/value pairs of the map MAP and thus creates a new map. For each key/value pair of the map MAP the expression EXPR is evaluated in a new context, where the variable KEY is assigned to the key and VALUE to the value of the pair. The result is the map of those evaluations.

The result of each evaluation must be a map with a single entry which will be added to the result map.

Parameters:
any KEY
any VALUE
map MAP
block EXPR
Returns:
map
mapmap (integer k, string v, $[1:"a", 2:"b"], { return ($[k+10 : v+"x"]); }) -> $[ 11:"ax", 12:"bx" ] mapmap (integer k, string v, $[1:"a", 2:"b"], { integer a = k + 10; string b = v + "x"; return $[a:b]; }) -> $[ 11:"ax", 12:"bx" ]

static YCPValue m_remove const YCPMap map,
const YCPValue key
[static]
 

Remove key/value pair from a map.

remove

Remove the value with the key KEY from a map. Returns nil if the key is invalid.

Parameters:
map MAP
any KEY
Returns:
map
remove($[1:2], 0) -> nil remove($[1:2], 1) -> $[] remove ($[1:2, 3:4], 1) -> $[3:4]

static YCPValue m_size const YCPValue map  )  [static]
 

Size of a map.

size

Returns the number of key/value pairs in the map MAP.

Parameters:
map MAP
Returns:
integer
size($["a":1, "aa":2, "b":3]) -> 3

static YCPValue m_tomap const YCPValue v  )  [static]
 

Converts a value to a map.

tomap

If the value can't be converted to a map, nilmap is returned. Functionality partly replaced with retyping: any a = $[1:1, 2:2]; map m = (map) a;

Parameters:
any VALUE
Returns:
map

static YCPValue m_unionmap const YCPMap map1,
const YCPMap map2
[static]
 

Union of 2 maps Interprets two maps as sets and returns a new map that has all elements of the first map MAP1and all of the second map MAP2. If elements have identical keys, values from MAP2 overwrite elements from MAP1.

union

Parameters:
map MAP1
map MAP2
Returns:
map
union($["a":1, "b":2], $[1:"a", 2:"b"]) -> $[1:"a", 2:"b", "a":1, "b":2] union($["a":1, "b":2], $["b":10, "c":20]) -> $["a":1, "b":10, "c":20]


Variable Documentation

StaticDeclaration static_declarations
 


Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6