ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
popKeyVal.m
Go to the documentation of this file.
1%> \brief
2%> Return the input ``hashmap`` while all cases
3%> of keys matching the input ``keys`` are deleted
4%> along with their corresponding values immediately
5%> appearing after the elements matching the input ``keys``.
6%>
7%> \param[in] keys : The input MATLAB cell array of rank 1 containing
8%> the key(s) to search for in the input pair list.
9%> \param[in] hashmap : The input cell array of even number of elements
10%> containing the ``(key, val)`` pairs of the input
11%> ``hashmap`` in sequence as element of the cell array.
12%>
13%> \return
14%> ``keyval`` : The output cell array of even number of elements
15%> containing the ``(key, val)`` pairs of the keys
16%> in the input argument ``keys``.<br>
17%> ``hashout`` : The output cell array of even number of elements
18%> containing the ``(key, val)`` pairs of the input
19%> ``hashmap`` while all instances of keys matching
20%> the input ``keys`` along with their values are deleted.<br>
21%>
22%> \interface{popKeyVal}
23%> \code{.m}
24%>
25%> [keyval, hashout] = pm.matlab.hashmap.popKeyVal(keys, hashmap)
26%>
27%> \endcode
28%>
29%> \example{popKeyVal}
30%> \include{lineno} example/matlab/hashmap/popKeyVal/main.m
31%> \output{popKeyVal}
32%> \include{lineno} example/matlab/hashmap/popKeyVal/main.out.m
33%>
34%> \final{popKeyVal}
35%>
36%> \author
37%> \JoshuaOsborne, May 21 2024, 10:49 PM, University of Texas at Arlington<br>
38%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
39%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
40function [keyval, hashout] = popKeyVal(keys, hashmap)
41 vararginLen = length(hashmap);
42 if mod(vararginLen, 2) ~= 0
43 help("pm.matlab.hashmap.popKeyVal");
44 error ( newline ...
45 + "The length of ``hashmap`` must be even." + newline ...
46 + newline ...
47 + "length(hashmap) = " + string(vararginLen) + newline ...
48 + newline ...
49 );
50 end
51 hashout = cell(length(hashmap), 1);
52 keyval = cell(length(hashmap), 1);
53 counter = 0;
54 kvcount = 0;
55 strkeys = string(keys);
56 for jkey = 1 : 2 : vararginLen
57 if ~any(strcmpi(string(hashmap{jkey}), strkeys))
58 counter = counter + 1;
59 hashout{counter} = hashmap{jkey};
60 counter = counter + 1;
61 hashout{counter} = hashmap{jkey + 1};
62 else
63 kvcount = kvcount + 1;
64 keyval{kvcount} = hashmap{jkey};
65 kvcount = kvcount + 1;
66 keyval{kvcount} = hashmap{jkey + 1};
67 end
68 end
69 hashout = hashout(1 : counter);
70 keyval = keyval(1 : kvcount);
71end
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function popKeyVal(in keys, in hashmap)
Return the input hashmap while all cases of keys matching the input keys are deleted along with their...