entries
Description
Examples
Entries of Dictionary
Create a dictionary containing several key-value pairs.
names = ["Unicycle" "Bicycle" "Tricyle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricyle"
Use entries
to return a table containing the entries stored in d
.
E = entries(d)
E=3×2 table
Key Value
___ __________
1 "Unicycle"
2 "Bicycle"
3 "Tricyle"
Entries of Dictionary as Structure
Create a dictionary containing several key-value pairs.
names = ["Unicycle" "Bicycle" "Tricyle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricyle"
Use entries
and specify the output format as "struct"
to return a struct
array containing the entries stored in d
.
E = entries(d,"struct")
E=3×1 struct array with fields:
Key
Value
Input Arguments
d
— Dictionary
dictionary
object
Dictionary, specified as a dictionary
object. If d
is unconfigured, entries
throws
an error.
format
— Output format
"table"
(default) | "struct"
| "cell"
Output format, specified as one of these values:
"table"
— Return key-value pairs in a table. This format is the default output format."struct"
— Return ann
-by-1 struct array, where each of then
struct
elements has the fieldskey
andvalue
corresponding to each of then
entries in the specified dictionary. Use this option for data types that are not compatible with tables."cell"
— Return key-value pairs in an
-by-2 cell array wheren
is the number of entries, the first column contains keys, and the second column contains values.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The
format
argument must be constant.If the
format
argument is"table"
, the dictionary cannot be empty at runtime. Dictionary keys and values must be numeric types, character arrays, structures, cell arrays, or enumerations.If the
format
argument is"cell"
, all keys and values must have the same type.The code generator does not treat a dictionary as a constant, even if the dictionary is constant at code generation time. This means that the
entries
function does not return constants. You cannot pass the output of theentries
function to a function that requires constant inputs. You cannot use the output of theentries
function for operations that require constants, such as indexing into a heterogeneous cell array. The code generator also cannot perform optimizations that depend on constants, such as constant folding, on the output of theentries
function.
For additional considerations that apply when generating C/C++ code for MATLAB® dictionaries, see Dictionary Limitations for Code Generation (MATLAB Coder).
Version History
Introduced in R2022bR2024b: Code generation support
You can generate C/C++ code for the dictionary entries
function.
See Also
dictionary
| configureDictionary
| insert
| lookup
| remove
| keys
| values
| types
| numEntries
| isConfigured
| isKey
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)