package nodeset

import (
	
)

// 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();  {
		return parallel.Fold(.Len(), ,
			func( ,  int)  { return (, +uint32()) },
			)
	}
	 := .ToSlice()
	return parallel.Fold(len(), ,
		func( ,  int)  { return (, []) },
		)
}