bugGNU Octave - Bugs: bug #63154, Implementation of dictionary

 
 

bug #63154: Implementation of dictionary

Submitter:  Guillaume <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:  In Progress Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Wed 05 Oct 2022 11:40:39 AM UTC, comment #2: 

New version with automatic conversion of keys and values from char to string if a string class is available.

(file #53795)

Guillaume <gyom>
Tue 04 Oct 2022 09:02:24 PM UTC, comment #1: 

File attached.

(file #53789)

Guillaume <gyom>
Tue 04 Oct 2022 08:20:10 PM UTC, original submission:  

See thread on Discourseabout 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 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.

Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53795:  dictionary.m added by gyom (18KiB - text/x-objcsrc)
file #53789:  dictionary.m added by gyom (17KiB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-05 gyom Attached File- Added dictionary.m, #53795
    2022-10-04 rik5 StatusNone In Progress
    2022-10-04 gyom Attached File- Added dictionary.m, #53789

    Back to the top


    Powered by Savane 3.9