R: Dictionary (R implementation)

DictL {collections} | R Documentation

## Dictionary (R implementation)

### Description

The `DictL` function creates an ordinary (unordered) dictionary (a.k.a. hash). Pure R implementation for benchmarking.

### Usage

    DictL(items = NULL)

### Arguments

`items` | a list of items

### Details

Following methods are exposed:

    .$set(key, value)
    .$get(key, default)
    .$remove(key)
    .$pop(key, default)
    .$has(key)
    .$keys()
    .$values()
    .$update(d)
    .$clear()
    .$size()
    .$as_list()
    .$print()

- `key`: any R object, key of the item

- `value`: any R object, value of the item

- `default`: optional, the default value of an item if the key is not found

### See Also

OrderedDict and OrderedDictL

### Examples

    d <- DictL(list(apple = 5, orange = 10))
    d$set("banana", 3)
    d$get("apple")
    d$as_list()  # unordered
    d$pop("orange")
    d$as_list()  # "orange" is removed
    d$set("orange", 3)$set("pear", 7)  # chain methods

[Package collections version 0.2.3 Index]