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

Post a Comment

Add a New Comment Rich Markup
   

Discussion

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.mathw ... b/dictionary.html
https://blogs.mat ... 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>

 

Attached Files

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

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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 group members can vote.

     

    History

    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.16-ed84.
    Corresponding source code