values

Class: containers.Map
Package: containers

Identify values in containers.Map object

Syntax

valueSet = values(mapObj)
valueSet = values(mapObj,keySet)

Description

valueSet = values(mapObj) returns all of the values in mapObj.

valueSet = values(mapObj,keySet) returns values that correspond to the specified keys.

Input Arguments

mapObj

Object of class containers.Map.

keySet

Cell array that specifies keys in mapObj.

Output Arguments

valueSet

Cell array containing values from mapObj. If you specify keySet, the valueSet array has the same size and dimensions as keySet.

Examples

Get All Values in a Map

Create a map, and view all values in the map:

myKeys = {'a','b','c'};
myValues = [1,2,3];
mapObj = containers.Map(myKeys,myValues);

valueSet = values(mapObj)

This code returns 1-by-3 cell array valueSet:

valueSet = 
    [1]    [2]    [3]

Get Selected Values in a Map

View the values corresponding to keys a and c in mapObj, created in the previous example:

keySet = {'a','c'};
valueSet = values(mapObj,keySet)

This code returns 1-by-2 cell array valueSet:

valueSet = 
    [1]    [3]

See Also

| |

Was this topic helpful?