Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Tourney.Match.Matrix
Description
Sparse matrices for holding matches
Synopsis
- data MatchMatrix
- newtype MapByRound a = ByRound (IntMap a)
- vectorMapByRound :: Vector a -> MapByRound a
- newtype MapByMatches a = ByMatches (IntMap (IntMap a))
- createMatchMatrix :: PlayerCount -> STM MatchMatrix
- readMatchMatrix :: MatchMatrix -> STM (MapByRound (MapByMatches (Maybe Result)))
- getMatch :: MatchMatrix -> RoundNo -> Match -> STM (Maybe (Maybe Result))
- getMatches :: MatchMatrix -> RoundNo -> STM (Vector (Match, Maybe Result))
- getMatchResults :: MatchMatrix -> RoundNo -> STM (Vector MatchResult)
- addMatch :: MatchMatrix -> RoundNo -> Match -> STM ()
- setMatchResult :: MatchMatrix -> RoundNo -> Match -> Result -> STM ()
- getPendingMatches :: MatchMatrix -> RoundNo -> STM (Vector Match)
- pendingMatchCount :: MatchMatrix -> RoundNo -> STM Int
- haveAnyPendingMatchesWithin :: MatchMatrix -> RoundNo -> Focus -> STM Bool
Documentation
data MatchMatrix Source #
An abstraction around a mutable store of rounds of matches and their results. Conceptually it stores a matrix of matches by (round, player1, player2), and a variable for the current round.
Instances
Generic MatchMatrix Source # | |
Defined in Tourney.Match.Matrix Methods from :: MatchMatrix -> Rep MatchMatrix x Source # to :: Rep MatchMatrix x -> MatchMatrix Source # | |
type Rep MatchMatrix Source # | |
Defined in Tourney.Match.Matrix |
newtype MapByRound a Source #
Instances
vectorMapByRound :: Vector a -> MapByRound a Source #
newtype MapByMatches a Source #
A sparse matrix for storing a map between matches and a value.
Since the two players in Match
are guaranteed to be ordered (low, high) we
only need to ever check the low->high->match path in the nested intmaps.
Instances
readMatchMatrix :: MatchMatrix -> STM (MapByRound (MapByMatches (Maybe Result))) Source #
getMatches :: MatchMatrix -> RoundNo -> STM (Vector (Match, Maybe Result)) Source #
getMatchResults :: MatchMatrix -> RoundNo -> STM (Vector MatchResult) Source #
addMatch :: MatchMatrix -> RoundNo -> Match -> STM () Source #
Add a match. It must not exist already in the current round
setMatchResult :: MatchMatrix -> RoundNo -> Match -> Result -> STM () Source #
Set a match result. It must already exist in the current round, by
addMatch
getPendingMatches :: MatchMatrix -> RoundNo -> STM (Vector Match) Source #
pendingMatchCount :: MatchMatrix -> RoundNo -> STM Int Source #
haveAnyPendingMatchesWithin :: MatchMatrix -> RoundNo -> Focus -> STM Bool Source #