deckarep / golang-set

A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.
Other
4.15k stars 274 forks source link

Is there any method to know whether a set is empty? #132

Closed Derick317 closed 11 months ago

Derick317 commented 11 months ago

Is there any method to know whether a set is empty? Or is there any method to get the number of elements in a set?

deckarep commented 11 months ago

Hi @Derick317,

Actually the closest thing is to check Cardinality with 0 but this is such a common thing to do that I think it’s worth adding a dedicated method for this.

An IsEmpty method should probably be added. I can do this or if you are more than welcome to.

deckarep commented 11 months ago

Closing as this was completed by @Jibaru - Thank You! And Thank You @Derick317 for the suggestion!