mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Provide additional methods under the CPUSet
- ToSliceInt64 returns sorted slice of cores IDs in int64 format - ToSliceNoSortInt64 returns slice of cores IDs in int64 format Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
This commit is contained in:
parent
3b38f6a08e
commit
69db36b958
@ -19,11 +19,12 @@ package cpuset
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"k8s.io/klog/v2"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// Builder is a mutable builder for CPUSet. Functions that mutate instances
|
||||
@ -198,6 +199,27 @@ func (s CPUSet) ToSliceNoSort() []int {
|
||||
return result
|
||||
}
|
||||
|
||||
// ToSliceInt64 returns an ordered slice of int64 that contains all elements from
|
||||
// this set
|
||||
func (s CPUSet) ToSliceInt64() []int64 {
|
||||
var result []int64
|
||||
for cpu := range s.elems {
|
||||
result = append(result, int64(cpu))
|
||||
}
|
||||
sort.Slice(result, func(i, j int) bool { return result[i] < result[j] })
|
||||
return result
|
||||
}
|
||||
|
||||
// ToSliceNoSortInt64 returns a slice of int64 that contains all elements from
|
||||
// this set.
|
||||
func (s CPUSet) ToSliceNoSortInt64() []int64 {
|
||||
var result []int64
|
||||
for cpu := range s.elems {
|
||||
result = append(result, int64(cpu))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// String returns a new string representation of the elements in this CPU set
|
||||
// in canonical linux CPU list format.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user