numEntries

Number of key-value entries in a dictionary.

Category: Language Fundamentals > Data Types

Syntax

n = numEntries(D)

Returns the number of entries stored in dictionary D.

Description

A dictionary maps unique keys to values. numEntries counts the keys, so an empty dictionary gives 0. It is the dictionary counterpart of numel for ordinary arrays and of the Count property of containers.Map.

Input arguments

D
A dictionary object.

Output arguments

n
Non-negative integer: how many keys D holds.

Example

d = dictionary(["a" "b"], [1 2]);
numEntries(d)
numEntries(dictionary)
Output
ans = 2
ans = 0

See also

dictionary keys values isKey remove containers.Map