meekstv

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 6 Imported by: 2

README

meekstv

Go Report Card Build Status

An implementation of Algorithm 123 - single transferable vote by Meek's Method

Background and specifications: https://svn.apache.org/repos/asf/steve/trunk/stv_background/meekm.pdf

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BySnapshotVotes added in v0.2.0

type BySnapshotVotes []MeekCandidate

func (BySnapshotVotes) Len added in v0.2.0

func (c BySnapshotVotes) Len() int

func (BySnapshotVotes) Less added in v0.2.0

func (c BySnapshotVotes) Less(i, j int) bool

func (BySnapshotVotes) Swap added in v0.2.0

func (c BySnapshotVotes) Swap(i, j int)

type ByVotes

type ByVotes MeekCandidates

func (ByVotes) Len

func (c ByVotes) Len() int

func (ByVotes) Less

func (c ByVotes) Less(i, j int) bool

func (ByVotes) Swap

func (c ByVotes) Swap(i, j int)

type CandidateStatus

type CandidateStatus string
const (
	Elected      CandidateStatus = "Elected"
	NewlyElected CandidateStatus = "NewlyElected"
	Hopeful      CandidateStatus = "Hopeful"
	Excluded     CandidateStatus = "Excluded"
	Almost       CandidateStatus = "Almost"
)

type MeekCandidate

type MeekCandidate struct {
	election.Candidate
	Status CandidateStatus
	Weight int64
	Votes  int64
}

func (*MeekCandidate) AsCandidate

func (meekCandidate *MeekCandidate) AsCandidate() election.Candidate

type MeekCandidates

type MeekCandidates []*MeekCandidate

func (MeekCandidates) AsCandidates

func (meekCandidates MeekCandidates) AsCandidates() election.Candidates

func (MeekCandidates) Snapshot added in v0.2.3

func (m MeekCandidates) Snapshot() []MeekCandidate

func (MeekCandidates) SortedNames added in v0.2.0

func (m MeekCandidates) SortedNames() []string

func (MeekCandidates) TotalVotes added in v0.2.0

func (m MeekCandidates) TotalVotes() int64

type MeekRound

type MeekRound struct {
	Number     int
	Excess     int64
	Surplus    int64
	AnyElected bool
	Snapshot   []MeekCandidate
}

type MeekStv

type MeekStv interface {
	election.Counter
}

func NewMeekStv

func NewMeekStv() MeekStv

type Pool

type Pool struct {
	MeekCandidates MeekCandidates
}

func (*Pool) AddNewCandidates

func (p *Pool) AddNewCandidates(candidates election.Candidates, scale int64)

func (*Pool) AddVotes added in v0.2.0

func (p *Pool) AddVotes(id string, votes int64)

func (*Pool) Almost

func (p *Pool) Almost() MeekCandidates

func (*Pool) Candidate

func (p *Pool) Candidate(id string) *MeekCandidate

func (*Pool) CandidateSummaries added in v0.1.0

func (p *Pool) CandidateSummaries() []election.CandidateSummary

func (*Pool) Candidates

func (p *Pool) Candidates() MeekCandidates

func (*Pool) CandidatesWithStatus added in v0.2.0

func (p *Pool) CandidatesWithStatus(status CandidateStatus) MeekCandidates

func (*Pool) Count

func (p *Pool) Count() int

func (*Pool) Elect

func (p *Pool) Elect(id string) *MeekCandidate

func (*Pool) ElectAllNewlyElected

func (p *Pool) ElectAllNewlyElected()

func (*Pool) ElectHopeful

func (p *Pool) ElectHopeful()

func (*Pool) Elected

func (p *Pool) Elected() MeekCandidates

func (*Pool) ElectedCount

func (p *Pool) ElectedCount() int

func (*Pool) Exclude

func (p *Pool) Exclude(id string) *MeekCandidate

func (*Pool) ExcludeByName

func (p *Pool) ExcludeByName(name string) MeekCandidates

func (*Pool) ExcludeHopeful

func (p *Pool) ExcludeHopeful()

func (*Pool) ExcludeMany added in v0.2.0

func (p *Pool) ExcludeMany(m MeekCandidates)

func (*Pool) ExcludedCount

func (p *Pool) ExcludedCount() int

func (*Pool) Hopeful

func (p *Pool) Hopeful() MeekCandidates

func (*Pool) Lowest

func (p *Pool) Lowest() MeekCandidates

func (*Pool) NewlyElect

func (p *Pool) NewlyElect(id string)

func (*Pool) NewlyElected

func (p *Pool) NewlyElected() MeekCandidates

func (*Pool) SetAlmost

func (p *Pool) SetAlmost(id string)

func (*Pool) SetWeight

func (p *Pool) SetWeight(id string, weight int64)

func (*Pool) Snapshot added in v0.2.0

func (p *Pool) Snapshot() []MeekCandidate

func (*Pool) ZeroAllVotes

func (p *Pool) ZeroAllVotes()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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