How to loop a HashSet? #41

Closed
opened 2016-11-22 02:42:36 +00:00 by tooooolong · 2 comments
tooooolong commented 2016-11-22 02:42:36 +00:00 (Migrated from github.com)

HI, how can i loop a HashSet, i see only TreeSet has a iterator thx!

HI, how can i loop a HashSet, i see only TreeSet has a iterator thx!
tooooolong commented 2016-11-22 05:15:33 +00:00 (Migrated from github.com)
ids  := set.Values()
for _, id := range(ids){
}

i iterate the set by this way. but if the set is too large, this approach will get a performance problem, is it?

``` ids := set.Values() for _, id := range(ids){ } ``` i iterate the set by this way. but if the set is too large, this approach will get a performance problem, is it?
emirpasic commented 2016-11-22 11:44:28 +00:00 (Migrated from github.com)

You can't loop the HashSet. HashSet is based on Go's map whose key (thus values in the set) order is random each time. Perhaps you are fine with that random order, in which case I could enable it?

You can't loop the HashSet. HashSet is based on Go's map whose key (thus values in the set) order is random each time. Perhaps you are fine with that random order, in which case I could enable it?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
golibs/gms-gods#41
No description provided.