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

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

[Octave-bug-tracker] [bug #63154] Implementation of dictionary


From: Guillaume
Subject: [Octave-bug-tracker] [bug #63154] Implementation of dictionary
Date: Tue, 4 Oct 2022 16:20:11 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?63154>

                 Summary: Implementation of dictionary
                 Project: GNU Octave
               Submitter: gyom
               Submitted: Tue 04 Oct 2022 08:20:10 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Feature Request
                  Status: None
             Assigned to: None
         Originator Name: Guillaume
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 04 Oct 2022 08:20:10 PM UTC By: Guillaume <gyom>
See thread on Discourse
<https://octave.discourse.group/t/adding-hashmaps-to-octave/3306>about a
dictionary class:
https://www.mathworks.com/help/matlab/dictionary.html
https://blogs.mathworks.com/matlab/2022/09/15/an-introduction-to-dictionaries-associative-arrays-in-matlab/

I attach my current attempt at implementing it. It requires a keyHash function
<https://www.mathworks.com/help/matlab/ref/keyhash.html> to be implemented and
so far I use:

++
## -*- texinfo -*-
## @deftypefn {} {@var{hashval} =} keyHash (@var{val})
## Calculate a uint64 hash value of the variable @var{val}.
##
## @seealso{keyMatch, dictionary}
## @end deftypefn

function hashval = keyHash (val)

  hashval = hash ("sha1", jsonencode (val));
  hashval = typecast (hashval(1:8), "uint64");

endfunction
--

A string class is nearly essential here otherwise make sure to only use char
scalars as keys or values. I tested the code with the string implementation
from octave-tablicious <https://github.com/apjanke/octave-tablicious>.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63154>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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