diff --git a/comsoc/tieBreak.go b/comsoc/tieBreak.go index 24f91cd401f53bf2fe42dd506d39874583717e0e..5fbe9eabe9be60abccd49c976248082a1967768b 100644 --- a/comsoc/tieBreak.go +++ b/comsoc/tieBreak.go @@ -1 +1,51 @@ package comsoc + +import("errors") + +func TieBreakFactory(tieBreakAlts []Alternative) (func ([]Alternative) (Alternative, err error)) { + return func(alts []Alternative) (Alternative, err error) { + if len(alts) == 0 || alts == nil { + return -1, errors.New("002: NullAlternatives") + } + + for _,alt := range(alts) { + for _,tieBreakAlt := range(tieBreakAlts) { + if alt == tieBreakAlt { + return alt, nil + } + } + } + return -1, errors.New("002: NoTieBreakAlternativeFound") + } +} + +func SWFFactory(swf1 func (Profile) (Count, error), tieBreak func ([]Alternative) (Alternative, error)) (swf2 func(Profile) (alts []Alternative, err error)) { + return func(p Profile) (alts Alternative, err error) { + // alts, _ := maxCount(swf1(p)) + // alt, _ := tieBreak(alts) + // return alt, nil + // il faut trifouiller le count + } +} + + +func SCFFactory(scf1 func (Profile) ([]Alternative, error), tieBreak func ([]Alternative) (Alternative, error)) (scf2 func(Profile) (alt Alternative, err error)) { + return func(p Profile) (alt Alternative, err error) { + alts, _ := scf1(p) + alt, _ := tieBreak(alts) + return alt, nil + } +} + + + + +// func TieBreak(a []Alternative) (Alternative, err error) { +// // if len(a) == 0 || a == nil { +// // return _, errors.New("002: NullAlternatives") +// // } +// // for _,alt := range a { +// // +// // } // 0-votes alternatives are not included +// // return nil, nil +// }