Using safer function Max

master
Uriel Fanelli 2023-08-12 23:56:25 +02:00
parent 8f3452988e
commit dfb1aa070a
1 changed files with 4 additions and 2 deletions

View File

@ -18,15 +18,17 @@ func (mip *AbstractMulticast) AddUniqueAndSort(hier int64) {
mip.HierarchyArray = append(mip.HierarchyArray, hier) mip.HierarchyArray = append(mip.HierarchyArray, hier)
sort.Slice(mip.HierarchyArray, func(i, j int) bool { return mip.HierarchyArray[i] < mip.HierarchyArray[j] }) sort.Slice(mip.HierarchyArray, func(i, j int) bool { return mip.HierarchyArray[i] < mip.HierarchyArray[j] })
log.Println("Here the numbers known:", mip.HierarchyArray) log.Println("Here the numbers known:", mip.HierarchyArray)
} }
} }
func (mip *AbstractMulticast) IsAlpha(hier int64) bool { func (mip *AbstractMulticast) IsAlpha(hier int64) bool {
log.Println("Element 0 is :", mip.HierarchyArray[0]) alpha := slices.Max(mip.HierarchyArray)
log.Println("Maximum element is :", alpha)
return mip.HierarchyArray[0] == hier return alpha == hier
} }