ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
popKeyVal.m File Reference

Go to the source code of this file.

Functions

function popKeyVal (in keys, in hashmap)
 Return the input hashmap while all cases of keys matching the input keys are deleted along with their corresponding values immediately appearing after the elements matching the input keys. More...
 

Function Documentation

◆ popKeyVal()

function popKeyVal ( in  keys,
in  hashmap 
)

Return the input hashmap while all cases of keys matching the input keys are deleted along with their corresponding values immediately appearing after the elements matching the input keys.

Parameters
[in]keys: The input MATLAB cell array of rank 1 containing the key(s) to search for in the input pair list.
[in]hashmap: The input cell array of even number of elements containing the (key, val) pairs of the input hashmap in sequence as element of the cell array.
Returns
keyval : The output cell array of even number of elements containing the (key, val) pairs of the keys in the input argument keys.
hashout : The output cell array of even number of elements containing the (key, val) pairs of the input hashmap while all instances of keys matching the input keys along with their values are deleted.


Possible calling interfaces

[keyval, hashout] = pm.matlab.hashmap.popKeyVal(keys, hashmap)


Example usage

1cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
2addpath('../../../../'); % Add the ParaMonte library root directory to the search path.
3
4pm.matlab.show()
5pm.matlab.show('hashmap = {"key1", 1, "key2", "val2", "key3", false, "key2", "last"};')
6 hashmap = {"key1", 1, "key2", "val2", "key3", false, "key2", "last"};
7
8pm.matlab.show()
9pm.matlab.show('[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap);')
10 [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap);
11pm.matlab.show('keyval')
12pm.matlab.show( keyval )
13pm.matlab.show('hashout')
14pm.matlab.show( hashout )
15
16pm.matlab.show()
17pm.matlab.show('[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap);')
18 [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap);
19pm.matlab.show('keyval')
20pm.matlab.show( keyval )
21pm.matlab.show('hashout')
22pm.matlab.show( hashout )
23
24pm.matlab.show()
25pm.matlab.show('[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap(1:4));')
26 [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap(1:4));
27pm.matlab.show('keyval')
28pm.matlab.show( keyval )
29pm.matlab.show('hashout')
30pm.matlab.show( hashout )
31
32pm.matlab.show()
33pm.matlab.show('[keyval, hashout] = pm.matlab.hashmap.popKeyVal({"key2", "key1"}, hashmap(1:4));')
34 [keyval, hashout] = pm.matlab.hashmap.popKeyVal({"key2", "key1"}, hashmap(1:4));
35pm.matlab.show('keyval')
36pm.matlab.show( keyval )
37pm.matlab.show('hashout')
38pm.matlab.show( hashout )
39
40pm.matlab.show()
41pm.matlab.show('try; [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap(1:3)); catch me; disp(string(me.identifier) + string(me.message)); end')
42 try; [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap(1:3)); catch me; disp(string(me.identifier) + string(me.message)); end
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.

Example output
1
2hashmap = {"key1", 1, "key2", "val2", "key3", false, "key2", "last"};
3
4[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap);
5keyval
6keyval{1}
7key2
8keyval{2}
9val2
10keyval{3}
11key2
12keyval{4}
13last
14hashout
15hashout{1}
16key1
17hashout{2}
18 1
19hashout{3}
20key3
21hashout{4}
22 0
23
24[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap);
25keyval
26keyval{1}
27key3
28keyval{2}
29 0
30hashout
31hashout{1}
32key1
33hashout{2}
34 1
35hashout{3}
36key2
37hashout{4}
38val2
39hashout{5}
40key2
41hashout{6}
42last
43
44[keyval, hashout] = pm.matlab.hashmap.popKeyVal("key3", hashmap(1:4));
45keyval
46hashout
47hashout{1}
48key1
49hashout{2}
50 1
51hashout{3}
52key2
53hashout{4}
54val2
55
56[keyval, hashout] = pm.matlab.hashmap.popKeyVal({"key2", "key1"}, hashmap(1:4));
57keyval
58keyval{1}
59key1
60keyval{2}
61 1
62keyval{3}
63key2
64keyval{4}
65val2
66hashout
67
68try; [keyval, hashout] = pm.matlab.hashmap.popKeyVal("key2", hashmap(1:3)); catch me; disp(string(me.identifier) + string(me.message)); end
69 > \brief
70 > Return the input ``hashmap`` while all cases
71 > of keys matching the input ``keys`` are deleted
72 > along with their corresponding values immediately
73 > appearing after the elements matching the input ``keys``.
74 >
75 > \param[in] keys : The input MATLAB cell array of rank 1 containing
76 > the key(s) to search for in the input pair list.
77 > \param[in] hashmap : The input cell array of even number of elements
78 > containing the ``(key, val)`` pairs of the input
79 > ``hashmap`` in sequence as element of the cell array.
80 >
81 > \return
82 > ``keyval`` : The output cell array of even number of elements
83 > containing the ``(key, val)`` pairs of the keys
84 > in the input argument ``keys``.<br>
85 > ``hashout`` : The output cell array of even number of elements
86 > containing the ``(key, val)`` pairs of the input
87 > ``hashmap`` while all instances of keys matching
88 > the input ``keys`` along with their values are deleted.<br>
89 >
90 > \interface{popKeyVal}
91 > \code{.m}
92 >
93 > [keyval, hashout] = pm.matlab.hashmap.popKeyVal(keys, hashmap)
94 >
95 > \endcode
96 >
97 > \example{popKeyVal}
98 > \include{lineno} example/matlab/hashmap/popKeyVal/main.m
99 > \output{popKeyVal}
100 > \include{lineno} example/matlab/hashmap/popKeyVal/main.out.m
101 >
102 > \final{popKeyVal}
103 >
104 > \author
105 > \JoshuaOsborne, May 21 2024, 10:49 PM, University of Texas at Arlington<br>
106 > \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
107 > \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
108
109
110The length of ``hashmap`` must be even.
111
112length(hashmap) = 3
113
114
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...


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Joshua Alexander Osborne, May 21 2024, 10:49 PM, University of Texas at Arlington
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin