HeadlinesBriefing favicon HeadlinesBriefing.com

Go Proposal: New Generic Collection Types

Hacker News •
×

The Go Collections working group has proposed several new generic collection data structures for the standard library, aiming for pragmatism and simplicity.

Key additions include hash/maphash.Hasher for custom hash functions, container/hash.Map and container/hash.Set for hash-based collections, and container/set.Set for canonical sets of comparable elements. An ordered map, container/ordered.Map, is also proposed, using a balanced binary tree. The existing container/heap will be replaced by a generic container/heap/v2.Heap.

Abstract constraint interfaces (_Abstract Collection, _Abstract Map, _Abstract Set) are introduced internally to ensure API consistency across these new types. While not public yet, these interfaces guide the development and testing of the concrete collection types, aiming to establish conventions for future additions to Go's collection APIs.