removeDuplicates removes elements from uids if they are in set. It also adds all uids to set.
(uids []uint64, set map[uint64]struct{})
| 724 | // removeDuplicates removes elements from uids if they are in set. It also adds |
| 725 | // all uids to set. |
| 726 | func removeDuplicates(uids []uint64, set map[uint64]struct{}) []uint64 { |
| 727 | for i := 0; i < len(uids); i++ { |
| 728 | uid := uids[i] |
| 729 | if _, ok := set[uid]; ok { |
| 730 | copy(uids[i:], uids[i+1:]) |
| 731 | uids = uids[:len(uids)-1] |
| 732 | i-- // we just removed an entry, so go back one step |
| 733 | } else { |
| 734 | set[uid] = struct{}{} |
| 735 | } |
| 736 | } |
| 737 | return uids |
| 738 | } |
| 739 | |
| 740 | func paginate(ts *pb.SortMessage, dest *pb.List, vals []types.Val) (int, int, error) { |
| 741 | count := int(ts.Count) |