-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[simple_set] simple version of set #5920
Conversation
please add a method to get all the set elements, like:
|
Can you explain the necessity as |
Let’s first talk about this as this causes problems by exposing implementation details via the exposed order. There is a reason we do not have this for SimpleMap |
19bf563
to
f6dab42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one high-level question - you mentioned in the desc that requiring the items to be copyable/droppable simplifies remove. Is this referring to the fact that it doesn't need to return the removed value? I think these constraints might make SimpleSet a lot less useful as you can't use it with un-droppable objects.
A common use-case for Sets is to use them as an intermediary to dedupe values in a vector and return the deduped items as a simple vector. Order doesn't matter. |
@movekevin Think of undroppable(uncopyable) objects, how do you want to use it with |
Your point about copyable makes sense. But what about droppable? |
I'm fine with this, but I wonder why we didn't just make a dummy value and use SimpleMap.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can have this part of our framework and call it a "set" because it doesn't has a very simple property important for sets: equality. Equality of two sets with different order of insertion is not given.
Being able to compare sets for equality independent of insertion order is a very common use case for sets (I used it often in my daily programming). This cannot go like this into the framework.
Really torn about this. It feels this will be still a utility of use, but set equality is really a common use case (whereas map equality isn't, so SimpleMap not having this is ok). We are really doctoring around that we do not have an adequate native comparison operator in Move. We should add this one ASAP. In the meantime, maybe we should call this |
May be this can be provided with adding a native function for serializing the set into bytes that ensures order of elements? |
1 similar comment
May be this can be provided with adding a native function for serializing the set into bytes that ensures order of elements? |
I plan to reuse simple map with |
I took a look at cpp btw, in programming world, I think equality just means extensionality... So why would we bother to over-complicate the concept by giving such a name... |
do you want to rename this unordered_set? |
Why? Do you rename btw, do we have any plan to implement native implementation for simple_map that it reads a blob from storage and instantiate an in-memory hashmap/btreemap and serialize it into a deterministic binary format into |
We need to discuss perhaps in person. I definitely are of the opinion a set type without correct equality cannot be part of the framework. The current simple_map is already bad enough. General and fast comparison is coming to Move. Then this can be done right. |
cc @movekevin .Please take a look at @wrwg 's comment. Then let's hold off putting this inside framework and you can use simple_map for now for multi-sig acct. |
Description
I simplified
insert
andremove
api by enforcingcopy + drop
Test Plan
ut