| 842 | } |
| 843 | |
| 844 | func (lhs *AsPathSet) Remove(arg DefinedSet) error { |
| 845 | if lhs.Type() != arg.Type() { |
| 846 | return fmt.Errorf("can't append to different type of defined-set") |
| 847 | } |
| 848 | newList := make([]*regexp.Regexp, 0, len(lhs.list)) |
| 849 | for _, x := range lhs.list { |
| 850 | found := false |
| 851 | for _, y := range arg.(*AsPathSet).list { |
| 852 | if x.String() == y.String() { |
| 853 | found = true |
| 854 | break |
| 855 | } |
| 856 | } |
| 857 | if !found { |
| 858 | newList = append(newList, x) |
| 859 | } |
| 860 | } |
| 861 | lhs.list = newList |
| 862 | newSingleList := make([]*singleAsPathMatch, 0, len(lhs.singleList)) |
| 863 | for _, x := range lhs.singleList { |
| 864 | found := slices.ContainsFunc(arg.(*AsPathSet).singleList, x.Equal) |
| 865 | if !found { |
| 866 | newSingleList = append(newSingleList, x) |
| 867 | } |
| 868 | } |
| 869 | lhs.singleList = newSingleList |
| 870 | return nil |
| 871 | } |
| 872 | |
| 873 | func (lhs *AsPathSet) Replace(arg DefinedSet) error { |
| 874 | rhs, ok := arg.(*AsPathSet) |