package nodesetimport ()// ParFold folds the set's ids in parallel, then merges the per-chunk// results: identity seeds each chunk's accumulator, fold folds one id into// an accumulator, and reduce merges two accumulators (merged in ascending// chunk order, so the result is deterministic for any associative reduce).// The parallelism is an implementation detail -- the signature is pure std,// so callers depend on neither a parallelism package nor the storage layout.// Uses the contiguous-range fast path (AsRange) when the ids are gap-free,// otherwise a collected scan. For a sequential fold use Iter.//// A package-level generic function rather than a method: Go methods cannot// have type parameters.func [ any]( *Set, func() , func( , uint32) , func(, ) ) {if , , := .AsRange(); {returnparallel.Fold(.Len(), ,func( , int) { return (, +uint32()) }, ) } := .ToSlice()returnparallel.Fold(len(), ,func( , int) { return (, []) }, )}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.