广告平台(站长下代理使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 月之前
12345678910111213141516171819202122232425262728293031323334353637
  1. package utils
  2. func RemoveDuplicateString(elms []string) []string {
  3. res := make([]string, 0, len(elms))
  4. temp := map[string]struct{}{}
  5. for _, item := range elms {
  6. if _, ok := temp[item]; !ok {
  7. temp[item] = struct{}{}
  8. res = append(res, item)
  9. }
  10. }
  11. return res
  12. }
  13. func RemoveDuplicateInt(elms []int) []int {
  14. res := make([]int, 0, len(elms))
  15. temp := map[int]struct{}{}
  16. for _, item := range elms {
  17. if _, ok := temp[item]; !ok {
  18. temp[item] = struct{}{}
  19. res = append(res, item)
  20. }
  21. }
  22. return res
  23. }
  24. func RemoveDuplicateInt64(elms []int64) []int64 {
  25. res := make([]int64, 0, len(elms))
  26. temp := map[int64]struct{}{}
  27. for _, item := range elms {
  28. if _, ok := temp[item]; !ok {
  29. temp[item] = struct{}{}
  30. res = append(res, item)
  31. }
  32. }
  33. return res
  34. }