2%> Return a ``hashmap`` cell array containing all field names
3%> and field values of input scalar MATLAB ``
object`` as ``(key, val)``
4%> stored sequentially in the cell array.<br>
6%> \param[in]
object : The input scalar MATLAB
struct
7%> whose field names and values are
8%> to be converted to a ``hashmap`` cell.<br>
9%> \param[in] exkeys : The input vector of MATLAB strings
10%> containing a
list of field names of the input ``
object``
11%> that must be
excluded from the output ``hashmap`` cell.<br>
12%> (**optional**,
default = ``[]``)
13%> \param[in] unique : The input scalar MATLAB logical.<br>
14%> If ``
true``, only the first instance of occurrence
15%> of any field
name is added to the output cell array
16%> without considering
case-sensitivity of the field names.<br>
17%> (**optional**,
default = ``
false``)
18%> \param[in] onlyfull : The input scalar MATLAB logical.
19%> If ``
true``, only the structure field names field values
20%> are nonempty (as assessed by the MATLAB intrinsic ``isempty()``)
21%> are included in the output ``hashmap``.<br>
22%> (**optional**,
default = ``
false``)
25%> ``hashmap`` : The output cell array of even number of elements
26%> containing the field names and values of the input ``
object``
27%> as ``(key, val)`` pairs stored sequentially as the cell elements.<br>
32%> hashmap = pm.matlab.hashmap.struct2hash(
object)
33%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys)
34%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], unique)
35%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, unique)
36%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, [], onlyfull)
37%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], unique, onlyfull)
38%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, unique, onlyfull)
39%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], [], onlyfull)
40%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], [], [])
45%> \include{lineno} example/matlab/hashmap/
struct2hash/main.m
47%> \include{lineno} example/matlab/hashmap/
struct2hash/main.out.m
52%> \JoshuaOsborne, May 21 2024, 10:56 PM, University of Texas at Arlington<br>
53%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
54%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
55function hashmap =
struct2hash(
object, exkeys, unique, onlyfull)
56 fnameList = fieldnames(
object);
57 fnameListLen = length(fnameList);
58 if nargin < 4; onlyfull = []; end
59 if nargin < 3; unique = []; end
60 if nargin < 2; exkeys = []; end
61 if isempty(unique); unique =
false; end
62 if isempty(onlyfull); onlyfull =
false; end
64 fnameListLower = lower(fnameList);
66 hashmap = cell(fnameListLen * 2, 1);
67 exkeys = string(exkeys);
69 for i = 1 : fnameListLen
70 fname = string(fnameList{i});
71 if ~any(strcmp(exkeys, fname))
72 if ~(onlyfull && isempty(
object.(fname))) && ~(unique && any(strcmpi(fnameListLower(1 : i - 1), fname)))
73 counter = counter + 1;
74 hashmap{counter} = fname;
75 counter = counter + 1;
76 hashmap{counter} =
object.(fname);
80 hashmap = hashmap(1 : counter);
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared library directories.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function struct2hash(in object, in exkeys, in unique, in onlyfull)
Return a hashmap cell array containing all field names and field values of input scalar MATLAB object...