emirpasic / gods

GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more
Other
16.32k stars 1.77k forks source link

Request: add methods Min() and Max() to TreeSet #259

Open miparnisari opened 3 months ago

miparnisari commented 3 months ago

I see that TreeSet is

type Set struct {
    tree *rbt.Tree
}

and rbt.Tree has Left() and Right() to get the min and max:

https://github.com/emirpasic/gods/blob/14f714261f50e6d3e4af1cd29e4ae11ffdedab94/trees/redblacktree/redblacktree.go#L196-L216

Can we expose those methods in the TreeSet too? The workaround of calling arr := treeset.Values() and then grabbing arr[0] and arr[len(arr)-1] seems very wasteful.

yossev commented 3 months ago

Should be there now.