|
202 | 202 | ## Check type of keys and values, and define numeric_keys
|
203 | 203 | check_types (this);
|
204 | 204 |
|
205 |
| - ## Flatten char keys |
206 |
| - if (! this.numeric_keys) |
207 |
| - keys = cellfun (@(x) x(:).', keys, 'UniformOutput', false); |
208 |
| - endif |
209 |
| - |
210 | 205 | ## Sort keys (faster than call to sort_keys once encoded)
|
211 | 206 | if (this.numeric_keys)
|
212 | 207 | [~, I] = sort (cell2mat (keys));
|
|
266 | 261 | if (! iscell (keySet))
|
267 | 262 | error ("containers.Map: input argument 'keySet' must be a cell");
|
268 | 263 | endif
|
269 |
| - if (! this.numeric_keys) |
270 |
| - ## Flatten char keys |
271 |
| - keySet = cellfun (@(x) x(:).', keySet, 'UniformOutput', false); |
272 |
| - endif |
273 | 264 | enckeySet = encode_keys (this, keySet);
|
274 | 265 | valueSet = cell (size (keySet));
|
275 | 266 | for i = 1:numel (valueSet)
|
|
307 | 298 | in = cellfun ("isnumeric", keySet) | cellfun ("islogical", keySet);
|
308 | 299 | if (! this.numeric_keys)
|
309 | 300 | in = ! in;
|
310 |
| - ## Flatten char keys |
311 |
| - keySet = cellfun (@(x) x(:).', keySet, 'UniformOutput', false); |
312 | 301 | endif
|
313 | 302 | keySet = encode_keys (this, keySet(in));
|
314 | 303 | tf(in) = isfield (this.map, keySet);
|
|
337 | 326 | in = cellfun ("isnumeric", keySet) | cellfun ("islogical", keySet);
|
338 | 327 | if (! this.numeric_keys)
|
339 | 328 | in = ! in;
|
340 |
| - ## Flatten char keys |
341 |
| - keySet = cellfun (@(x) x(:).', keySet, 'UniformOutput', false); |
342 | 329 | endif
|
343 | 330 | keySet = encode_keys (this, keySet(in));
|
344 | 331 | in = isfield (this.map, keySet);
|
|
447 | 434 | || ! isscalar (key))))
|
448 | 435 | error ("containers.Map: specified key type does not match the type of this container");
|
449 | 436 | endif
|
450 |
| - if (ischar (key)) |
451 |
| - key = key(:).'; |
452 |
| - endif |
453 | 437 | enckey = encode_keys (this, key);
|
454 | 438 | if (! isfield (this.map, enckey))
|
455 | 439 | error ("containers.Map: specified key <%s> does not exist",
|
|
489 | 473 | endif
|
490 | 474 | val = feval (this.ValueType, val);
|
491 | 475 | endif
|
492 |
| - if (ischar (key)) |
493 |
| - key = key(:).'; |
494 |
| - endif |
495 | 476 | key = encode_keys (this, key);
|
496 | 477 | if (isfield (this.map, key))
|
497 | 478 | this.map.(key) = val;
|
@@ -671,19 +652,6 @@ function check_types (this)
|
671 | 652 | %! m = containers.Map ('', 3);
|
672 | 653 | %! assert (m(''), 3);
|
673 | 654 |
|
674 |
| -## Test multi-row char array keys |
675 |
| -%!test <*67283> |
676 |
| -%! k1 = char ("key", "one"); |
677 |
| -%! k2 = char ("key", "two"); |
678 |
| -%! k3 = char ("key", "three"); |
679 |
| -%! m = containers.Map ({k1, k2}, {1, 2}); |
680 |
| -%! m(k3) = 3; |
681 |
| -%! assert (m(k1), 1); |
682 |
| -%! assert (m.values ({k1, k3}), {1, 3}); |
683 |
| -%! m.remove ({k1, k3}); |
684 |
| -%! assert (m(k2), 2); |
685 |
| -%! assert (m.isKey ({k1, k2, k3}), [false, true, false]); |
686 |
| -
|
687 | 655 | ## Test numeric keys
|
688 | 656 | %!test
|
689 | 657 | %! key = [1, 2, 3, 4];
|
|
0 commit comments