team

package
v0.1.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AreEnemyFunc

type AreEnemyFunc[T interface {
	Equals(other T) bool
}] func(m1, m2 T) (bool, error)

AreEnemyFunc is a function that checks if two members are enemies.

Parameters:

  • m1: The first member.
  • m2: The second member.

Returns:

  • bool: True if the members are enemies, false otherwise.
  • error: An error if the members are not valid.

type FilterFn

type FilterFn[T interface {
	Equals(other T) bool
}] func(league League[T]) bool

FilterFn is a filter function.

Parameters:

  • league: The league to filter.

Returns:

  • bool: True if the league should be kept, false otherwise.

func WithNTeams

func WithNTeams[T interface {
	Equals(other T) bool
}](n int) FilterFn[T]

WithNTeams returns a filter function that keeps only the specified number of teams.

Parameters:

  • n: The number of teams to keep.

Returns:

  • FilterFn: The filter function.

type League

type League[T interface {
	Equals(other T) bool
}] []Team[T]

League is a collection of teams.

func EvaluateTeams

func EvaluateTeams[T interface {
	Equals(other T) bool
}](members []T, enemy_fn AreEnemyFunc[T]) ([]League[T], error)

EvaluateTeams evaluates the teams.

Parameters:

  • members: the list of members to evaluate.
  • enemy_fn: the function to use to check for enemies.

Returns:

  • []League[T]: the list of teams. Never returns nil.
  • error: an error if the evaluation fails.

func FilterSolutions

func FilterSolutions[T interface {
	Equals(other T) bool
}](res []League[T], filter FilterFn[T]) []League[T]

FilterSolutions filters solutions based on a filter function.

Parameters:

  • res: The solutions to filter.
  • filter: The filter function.

Returns:

  • []League: The filtered solutions.

func (League[T]) ContainsTeam

func (l League[T]) ContainsTeam(team Team[T]) bool

ContainsTeam checks whether the league contains a team.

Parameters:

  • team: The team to check.

Returns:

  • bool: True if the league contains the team, false otherwise.

func (League[T]) Equals

func (l League[T]) Equals(other League[T]) bool

Equals checks whether two leagues are equal.

Two leagues are equal if they contain the same teams regardless of order.

Parameters:

  • other: The other league to compare to.

Returns:

  • bool: True if the leagues are equal, false otherwise.

type Team

type Team[T interface {
	Equals(other T) bool
}] []T

Team is a team of members.

func (Team[T]) Equals

func (t Team[T]) Equals(other Team[T]) bool

Equals checks whether two teams are equal.

Two teams are equal if they have the same members using a loose equality.

Parameters:

  • other: The other team to compare to.

Returns:

  • bool: True if the teams are equal, false otherwise.

func (Team[T]) HasMember

func (t Team[T]) HasMember(member T) bool

HasMember checks whether the team has a member.

Parameters:

  • member: the member to check.

Returns:

  • bool: true if the team has the member, false otherwise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL