ZhangZhihui's Blog |
|
||
2023年10月8日
摘要:
Problem: You want to create a set data structure. Solution: Wrap a struct around a map. Create set functions on the struct. A set is an unordered data 阅读全文
摘要:
Problem: You want to create a stack data structure. Solution: Wrap a struct around a slice. Create stack functions on the struct. A stack is a last-in 阅读全文
摘要:
Problem: You want to create a queue data structure. Solution: Wrap a struct around a slice. Create queue functions on the struct. A queue is a first-i 阅读全文
摘要:
Problem: You want to sort a map by its keys. Solution: Get the keys of the map in a slice and sort that slice. Then, using the sorted slice of keys, i 阅读全文
摘要:
Problem: You want to sort elements in an array or slice. Solution: For int , float64 , and string arrays or slices you can use sort.Ints , sort.Float6 阅读全文
摘要:
Problem: You want to make arrays and slices safe for concurrent use by multiple goroutines. Solution: Use a mutex from the sync library to safeguard t 阅读全文
|
Copyright © 2024 ZhangZhihuiAAA
Powered by .NET 9.0 on Kubernetes |