MCPcopy
hub / github.com/osrg/gobgp / Remove

Method Remove

internal/pkg/table/policy.go:844–871  ·  view source on GitHub ↗
(arg DefinedSet)

Source from the content-addressed store, hash-verified

842}
843
844func (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
873func (lhs *AsPathSet) Replace(arg DefinedSet) error {
874 rhs, ok := arg.(*AsPathSet)

Callers

nothing calls this directly

Calls 3

TypeMethod · 0.95
TypeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected