This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I created a class, creatively called dictionary2
which is really just an object which contains two dictionary
objects, where values of the first dictionary are the key's of the second, and the keys of the first are the values of the second. This allows very quick reverse look-up, and for my use case (needing to call it millions of times), the speed is important.
Everything works, except my object can't add key/value pairs using the
my_dict(keys) = values;
format, because best I can tell, user defined functions can't use that format. I believe if I extended the dictionary
class, there should be a way to do it, but I can't find any examples of how to use that format to both be a constructor, and to serve as an add
function.
Currently, I just have worked around this by just creating an add
method to my object, and it works but I was hoping I could get it to work so that everywhere in my code I currently have dictionary
I could just replace it with dictionary2
and otherwise it be invisible.
If anyone has a suggestion or know where I could look to accomplish this (or tell me it can't be done) that would be great.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/matlab/comm...