octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #49559] Implementation of containers.Map


From: Kai Torben Ohlhus
Subject: [Octave-bug-tracker] [bug #49559] Implementation of containers.Map
Date: Wed, 29 Mar 2017 08:07:27 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36

Follow-up Comment #13, bug #49559 (project octave):

Here my first review mostly trying all of MATLAB's documentation
https://www.mathworks.com/help/matlab/map-containers.html. I really can hardly
make up, whether I am using MATLAB's implementation or yours. Very impressive!
Only a few small things to make it perfectly indistinguishable:

a) I think Map.subsref, the cases "isKey" and "remove" are missing?


>> mapObj = containers.Map ({'a','b','c'}, {1,2,3});
>> mapObj.isKey('a')

error: The name 'isKey' is not an accessible property for an instance of class
'containers.Map'.
error: called from
    subsref at line 331 column 15
>> isKey (mapObj, 'a')

ans = 1
>> mapObj.remove('a')

error: The name 'remove' is not an accessible property for an instance of
class 'containers.Map'.
error: called from
    subsref at line 331 column 15
>> remove (mapObj, 'a')

containers.Map object with properties:

   Count     : 2
   KeyType   : char
   ValueType : double


b) There is a forgotten semicolon for the case "values" in Map.subsref.

c) Another one is performance:


Matlab R2017a:

>> n = 2e5; t1=tic; mapObj = containers.Map(num2cell(1:n),1:n); toc(t1),
t2=tic; mapObj(n-5), toc(t2)
Elapsed time is 0.155456 seconds.
ans =
      199995
Elapsed time is 0.000330 seconds.

Yours:

>> n = 2e3; t1=tic; mapObj = containers.Map(num2cell(1:n),1:n); toc(t1),
t2=tic; mapObj(n-5), toc(t2)
Elapsed time is 3.55376 seconds.
ans =    1.99500000000000e+03
Elapsed time is 0.00406289 seconds.


So it hardly works with 1e4 key-values. But I think this is acceptable.

d) Regarding the documentation, we have the convention to write two spaces
after a period, see http://wiki.octave.org/Help_text#Whitespace .


Some words.  Another words.


That's all. I am perfectly fine with it.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49559>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]