Skip to Main Content Skip to Search
Product Documentation

keys - Class: containers.Map
Package: containers

Identify keys of containers.Map object

Syntax

keySet = keys(mapObj)

Description

keySet = keys(mapObj) returns cell array keySet, which contains all of the keys in mapObj.

Input Arguments

mapObj

Object of class containers.Map.

Output Arguments

keySet

1-by-n cell array, where n is the number of keys in mapObj.

Examples

Get the Keys in a Map

Create a map, and view the keys in the map:

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

keySet = keys(mapObj)

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

keySet = 
    'a'    'b'    'c'

See Also

containers.Map | isKey | remove | values

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS