Documentation

values

Class:containers.Map
Package:containers

Identify values incontainers.Mapobject

Syntax

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

Description

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

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

Input Arguments

mapObj

Object of classcontainers.Map.

keySet

Cell array that specifies keys inmapObj.

Output Arguments

valueSet

Cell array containing values frommapObj. If you specifykeySet,valueSetarray has the same size and dimensions askeySet.

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 arrayvalueSet:

valueSet = [1] [2] [3]

Get Selected Values in a Map

View the values corresponding to keysaandcinmapObj, created in the previous example:

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

This code returns 1-by-2 cell arrayvalueSet:

valueSet = [1] [3]
Was this topic helpful?