Skip to content
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

ERL-557: is_empty/1 function missing from sets and ordsets #3436

Closed
OTP-Maintainer opened this issue Jan 31, 2018 · 2 comments
Closed

ERL-557: is_empty/1 function missing from sets and ordsets #3436

OTP-Maintainer opened this issue Jan 31, 2018 · 2 comments

Comments

@OTP-Maintainer
Copy link

Original reporter: juhlig
Affected version: Not Specified
Fixed in version: OTP-21.0
Component: stdlib
Migrated from: https://bugs.erlang.org/browse/ERL-557


The sets and ordsets modules don't have the is_empty/1 function to test if they're empty sets.

While this is ok for sets since size/1 is constant time there via the internal counter, the same is not true for ordsets, where size/1 maps on a length/1 call on the underlying list. Constant time test for an empty ordsets is only possible through dirty code.

The omission of the is_empty/1 function seems to be an oversight, the corresponding dict/orddict modules do have them, as do the gb_sets and gb_trees modules. Also, I see no reason why they should not have them. For sets it is the same as querying the size and comparing it to 0, with ordsets it is comparing the internal list with the empty list.

Though not neccesary for sets as outlined above, if an is_empty/1 function would be added to ordsets, it should be added to sets, too, since the two modules are supposed to exhibit the same interface.
@OTP-Maintainer
Copy link
Author

juhlig said:

See pull request #1703

@OTP-Maintainer
Copy link
Author

hasse said:

Merged 3514876e3c3d774f46ccd4b0bf04bffdba3e2987 into erlang:master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant