mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +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)
|
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.
|
// 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()
|
b := NewBuilder()
|
||||||
for cpu := range s.elems {
|
for cpu := range s.elems {
|
||||||
if predicate(cpu) {
|
if predicate(cpu) {
|
||||||
@ -107,19 +107,6 @@ func (s CPUSet) Filter(predicate func(int) bool) CPUSet {
|
|||||||
return b.Result()
|
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
|
// IsSubsetOf returns true if the supplied set contains all the elements
|
||||||
func (s CPUSet) IsSubsetOf(s2 CPUSet) bool {
|
func (s CPUSet) IsSubsetOf(s2 CPUSet) bool {
|
||||||
result := true
|
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
|
// that are present in both this set and the supplied set, without mutating
|
||||||
// either source set.
|
// either source set.
|
||||||
func (s CPUSet) Intersection(s2 CPUSet) CPUSet {
|
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
|
// 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
|
// are present in this set and not the supplied set, without mutating either
|
||||||
// source set.
|
// source set.
|
||||||
func (s CPUSet) Difference(s2 CPUSet) CPUSet {
|
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
|
// List returns a slice of integers that contains all elements from
|
||||||
|
Loading…
Reference in New Issue
Block a user