Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04 TP3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mohamed Fall
IA04 TP3
Commits
6a7d9731
Commit
6a7d9731
authored
2 years ago
by
Antoine Kryus
Browse files
Options
Downloads
Patches
Plain Diff
mov files
parent
a7e66d75
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comsoc/tieBreak.go
+50
-0
50 additions, 0 deletions
comsoc/tieBreak.go
with
50 additions
and
0 deletions
comsoc/tieBreak.go
+
50
−
0
View file @
6a7d9731
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
// }
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment