Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func unique(tokens *[]string) {
- v := reflect.ValueOf(tokens).Elem()
- if v.Len() <= 1 {
- return
- }
- sort.Strings(*tokens)
- i := 0
- for j := 1; j < v.Len(); j++ {
- if (*tokens)[i] == (*tokens)[j] {
- continue
- }
- // unique token, save it
- i++
- v.Index(i).Set(v.Index(j))
- }
- i++
- v.SetLen(i)
- }
Add Comment
Please, Sign In to add comment