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%> If the input argument ``unique`` is set to ``True``,
13%> then all elements of ``exkeys`` are compared to the
14%>
object field and subfield names
case-insensitively.<br>
15%> (**optional**,
default = ``[]``)
16%> \param[in] unique : The input scalar MATLAB logical.<br>
17%> If ``
true``, only the first instance of occurrence
18%> of any field
name is added to the output cell array
19%> without considering
case-sensitivity of the field names.<br>
20%> This argument also affects the input argument ``exkeys``.<br>
21%> (**optional**,
default = ``
false``)
22%> \param[in] onlyfull : The input scalar MATLAB logical.<br>
23%> If ``
true``, only the field names with field values that
24%> are nonempty (as assessed by the MATLAB intrinsic ``isempty()``)
25%> are included in the output ``hashmap``.<br>
26%> (**optional**,
default = ``
false``)
29%> ``hashmap`` : The output cell array of even number of elements
30%> containing the field names and values of the input ``
object``
31%> as ``(key, val)`` pairs stored sequentially as the cell elements.<br>
36%> hashmap = pm.matlab.hashmap.struct2hash(
object)
37%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys)
38%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], unique)
39%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, unique)
40%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, [], onlyfull)
41%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], unique, onlyfull)
42%> hashmap = pm.matlab.hashmap.struct2hash(
object, exkeys, unique, onlyfull)
43%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], [], onlyfull)
44%> hashmap = pm.matlab.hashmap.struct2hash(
object, [], [], [])
49%> \include{lineno} example/matlab/hashmap/
struct2hash/main.m
51%> \include{lineno} example/matlab/hashmap/
struct2hash/main.out.m
56%> \JoshuaOsborne, May 21 2024, 10:56 PM, University of Texas at Arlington<br>
57%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
58%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
59function hashmap =
struct2hash(
object, exkeys, unique, onlyfull)
60 fnameList = fieldnames(
object);
61 fnameListLen = length(fnameList);
62 if nargin < 4; onlyfull = []; end
63 if nargin < 3; unique = []; end
64 if nargin < 2; exkeys = []; end
65 if isempty(unique); unique =
false; end
66 if isempty(onlyfull); onlyfull =
false; end
67 hashmap = cell(fnameListLen * 2, 1);
68 exkeys = string(exkeys);
70 fnameListLower = lower(fnameList);
71 exkeys = lower(exkeys);
74 for i = 1 : fnameListLen
75 fname = string(fnameList{i});
76 if ~any(strcmp(exkeys, fname))
77 if ~(onlyfull && isempty(
object.(fname))) && ~(unique && any(strcmpi(fnameListLower(1 : i - 1), fname)))
78 counter = counter + 1;
79 hashmap{counter} = fname;
80 counter = counter + 1;
81 hashmap{counter} =
object.(fname);
85 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...