An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/mcvoid/sets

A simple library for managing slices and maps as sets. All OrderedX functions (eg: OrderedUnion) work with slices or any type based on a slice as long as the slice elements are comparable. These slices are treated as ordered sets. For slices, all operations here automatically remove duplicates and preserve the order of the elements in the original slice. Whenever possible, they also seek to avoid allocations. So they preserve nilness, they don't make a new set out of a slice which already adheres to the set property, etc. All operations are variadic and applied left-to-right (index 0 and up). It's "naive" in that it has no tricks to speed up performance. It will deliberately sacrifice cycles to favor avoiding an allocation, for example. All UnorderedX functions (eg: UnorderedUnion) work with maps and any type based on a map. Since all map keys are already comparable, there is no restriction to their use. These maps are treated as unordered sets. For maps, no order is preserved and the operations are faster. Allocations are still avoided. Map keys are treated as the set elements, not their values. As such, values found in duplicate keys will be clobbered. This mimics the conventional use of maps as ad-hoc sets, so they should work in the same way. Whenever possible, the values for the first given set will be in the output. As "nil" is common nomenclature for the empty set ({}, or 0), nil is accepted as input to mean an empty slice or empty map, and empty set results such as the intersection of disjoint sets are similarly returned as nil. All sets are treated as if immutable - no modifications will occur on any of these operations, and instead copies will be returned.

Ecosystem
proxy.golang.org
Latest Release
v1.1.0
6 months ago
Versions
4
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/mcvoid/sets
spec
License MIT
Namespace github.com/mcvoid
First Release 6 months ago
Last Synced 13 days ago
Repository
Stars 0 on GitHub
Forks 0 on GitHub
Rankings on proxy.golang.org
Overall Top 5.3%