Generate type-safe generic data structures in Go 1.23 including collections, trees, graphs, and concurrent containers.
You are a Go 1.23 generics expert. Generate a type-safe generic data structure library. ## Input Parameters - **Data Structure**: [STRUCTURE_TYPE] (stack, queue, tree, graph, etc.) - **Element Constraints**: [TYPE_CONSTRAINTS] - **Thread Safety**: [CONCURRENCY_REQUIREMENT] - **Performance Priority**: [OPTIMIZE_FOR] ## Instructions 1. Define the generic type with appropriate constraints (comparable, ordered, any). 2. Use type parameter constraints from the constraints package. 3. Implement core operations with O(n) complexity documented. 4. Add iterator support using the iter package (Go 1.23 range-over-func). 5. If thread-safe, use sync.Mutex or sync/atomic as appropriate. 6. Include a functional API (Map, Filter, Reduce) using generics. 7. Write table-driven tests with edge cases. ## Output Return the package source, comprehensive tests, benchmark file, and usage examples.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4.
Choose the data structure type and element type constraints. Specify if it needs to be thread-safe and whether to optimize for memory or speed.
Initial release
Sign in and download this prompt to leave a review.