mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
cpuset: hide 'Filter' API
FilterNot is only used in this file, and is trivially converted to a 'filter' call site by inverting the predicate. Filter is only used in this file, so don't export it.
This commit is contained in:
parent
e5143d16c2
commit
768b1ecfb6
@ -95,9 +95,9 @@ func (s CPUSet) Equals(s2 CPUSet) bool {
|
||||
return reflect.DeepEqual(s.elems, s2.elems)
|
||||
}
|
||||
|
||||
// Filter returns a new CPU set that contains all of the elements from this
|
||||
// filter returns a new CPU set that contains all of the elements from this
|
||||
// set that match the supplied predicate, without mutating the source set.
|
||||
func (s CPUSet) Filter(predicate func(int) bool) CPUSet {
|
||||
func (s CPUSet) filter(predicate func(int) bool) CPUSet {
|
||||
b := NewBuilder()
|
||||
for cpu := range s.elems {
|
||||
if predicate(cpu) {
|
||||
@ -107,19 +107,6 @@ func (s CPUSet) Filter(predicate func(int) bool) CPUSet {
|
||||
return b.Result()
|
||||
}
|
||||
|
||||
// FilterNot returns a new CPU set that contains all of the elements from this
|
||||
// set that do not match the supplied predicate, without mutating the source
|
||||
// set.
|
||||
func (s CPUSet) FilterNot(predicate func(int) bool) CPUSet {
|
||||
b := NewBuilder()
|
||||
for cpu := range s.elems {
|
||||
if !predicate(cpu) {
|
||||
b.Add(cpu)
|
||||
}
|
||||
}
|
||||
return b.Result()
|
||||
}
|
||||
|
||||
// IsSubsetOf returns true if the supplied set contains all the elements
|
||||
func (s CPUSet) IsSubsetOf(s2 CPUSet) bool {
|
||||
result := true
|
||||
@ -152,14 +139,14 @@ func (s CPUSet) Union(s2 ...CPUSet) CPUSet {
|
||||
// that are present in both this set and the supplied set, without mutating
|
||||
// either source set.
|
||||
func (s CPUSet) Intersection(s2 CPUSet) CPUSet {
|
||||
return s.Filter(func(cpu int) bool { return s2.Contains(cpu) })
|
||||
return s.filter(func(cpu int) bool { return s2.Contains(cpu) })
|
||||
}
|
||||
|
||||
// Difference returns a new CPU set that contains all of the elements that
|
||||
// are present in this set and not the supplied set, without mutating either
|
||||
// source set.
|
||||
func (s CPUSet) Difference(s2 CPUSet) CPUSet {
|
||||
return s.FilterNot(func(cpu int) bool { return s2.Contains(cpu) })
|
||||
return s.filter(func(cpu int) bool { return !s2.Contains(cpu) })
|
||||
}
|
||||
|
||||
// List returns a slice of integers that contains all elements from
|
||||
|
Loading…
Reference in New Issue
Block a user