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

Method Remove

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

Source from the content-addressed store, hash-verified

1792}
1793
1794func (s *ExtCommunitySet) Remove(arg DefinedSet) error {
1795 if s.Type() != arg.Type() {
1796 return fmt.Errorf("can't remove from different type of defined-set")
1797 }
1798 other := arg.(*ExtCommunitySet)
1799 newList := make([]*regexp.Regexp, 0, len(s.list))
1800 newSubtypes := make([]bgp.ExtendedCommunityAttrSubType, 0, len(s.subtypeList))
1801 for i, x := range s.list {
1802 found := false
1803 for _, y := range other.list {
1804 if x.String() == y.String() {
1805 found = true
1806 break
1807 }
1808 }
1809 if !found {
1810 newList = append(newList, x)
1811 newSubtypes = append(newSubtypes, s.subtypeList[i])
1812 }
1813 }
1814 s.list = newList
1815 s.subtypeList = newSubtypes
1816 s.rebuildExtMatchers()
1817 return nil
1818}
1819
1820func (s *ExtCommunitySet) Replace(arg DefinedSet) error {
1821 other, ok := arg.(*ExtCommunitySet)

Callers

nothing calls this directly

Calls 3

rebuildExtMatchersMethod · 0.95
TypeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected