Move heap into its own internal package

This commit is contained in:
Harsh Singh
2019-09-27 14:27:27 +05:30
parent ded22e3975
commit f462a31e9b
8 changed files with 79 additions and 40 deletions

View File

@@ -62,6 +62,10 @@ func GetPodStartTime(pod *v1.Pod) *metav1.Time {
return &metav1.Time{Time: time.Now()}
}
// lessFunc is a function that receives two items and returns true if the first
// item should be placed before the second one when the list is sorted.
type lessFunc = func(item1, item2 interface{}) bool
// GetEarliestPodStartTime returns the earliest start time of all pods that
// have the highest priority among all victims.
func GetEarliestPodStartTime(victims *extenderv1.Victims) *metav1.Time {
@@ -91,13 +95,9 @@ func GetEarliestPodStartTime(victims *extenderv1.Victims) *metav1.Time {
// SortableList is a list that implements sort.Interface.
type SortableList struct {
Items []interface{}
CompFunc LessFunc
CompFunc lessFunc
}
// LessFunc is a function that receives two items and returns true if the first
// item should be placed before the second one when the list is sorted.
type LessFunc func(item1, item2 interface{}) bool
var _ = sort.Interface(&SortableList{})
func (l *SortableList) Len() int { return len(l.Items) }