[−][src]Struct ultra_tournament::Tournament
Tournament<E, M, B>
is the core structure of the package. Creates a single-elimination tournament bracket.
E
- The entrant structs that will battle each other. Must implementDebug
,Display
andClone
.M
- The metadata struct that is added to rounds after being completed. Must implementDebug
,Display
,Clone
andDefault
B
- The battle system that solves rounds between two entrants of typeE
. Must implementBattleSystem<E, M>
Implementations
impl<E: Debug + Display + Clone, M: Debug + Display + Clone + Default, B: BattleSystem<E, M>> Tournament<E, M, B>
[src]
pub fn new(entrants: Vec<E>) -> Result<Self>
[src]
Create a new Tournament
from a Vec<E>
of entrant structs. Brackets are assigned in the Vec<E>
's order.
Example
Create a Tournament
that battles a vec of u32
s
use crate::{ MyBattleSystem, MyMetadata }; let entrants = vec![1, 2, 3, 23, 35, 483, 9494, 9, 0, 102, 48]; let t = Tournament::<u32, MyMetadata, MyBattleSystem>::new(entrants);
pub fn new_from_gen(size: usize, gen: fn() -> E) -> Result<Self>
[src]
Created a new Tournament
of a specified number of entrants, using a generation closure that returns a new entrant.
Example
Create a Tournament
that battles 200 randomly generated u32
s
use rand::prelude::*; use crate::{ MyBattleSystem, MyMetadata }; let t = Tournament::<u32, MyMetadata, MyBattleSystem>::new_from_gen( 200, || random::<u32>() );
pub fn len_entrants(&self) -> usize
[src]
Get the number of entrants in the tournament.
pub fn len_rounds(&self) -> usize
[src]
Get the number of rounds in the tournament, complete and incomplete.
pub fn len_rounds_complete(&self) -> usize
[src]
Get the number of completed rounds in the tournament.
pub fn len_rounds_incomplete(&self) -> usize
[src]
Get the number of incomplete rounds in the tournament.
pub fn entrant(&self, id: EntrantId) -> Arc<RwLock<E>>
[src]
Get an Arc<RwLock<E>>
encapsulating an entrant of specified EntrantId
pub fn grand_finals(&self) -> &NodeIndex
[src]
Get a ref to the NodeIndex
of the tournament's final round.
pub fn graph(&self) -> &Graph<TournamentNode<M>, TournamentEdge>
[src]
Get a ref to the internal Graph
used by the tournament. ultra_tournament
is built using the petgraph
crate.
pub fn child_node(
&self,
id: NodeIndex,
target: TournamentEdge
) -> Result<NodeIndex>
[src]
&self,
id: NodeIndex,
target: TournamentEdge
) -> Result<NodeIndex>
Get the NodeIndex
of a round leading to one with the index id
. Uses the TournamentEdge
to specify either A
or B
pub fn child_nodes(&self, id: NodeIndex) -> Result<(NodeIndex, NodeIndex)>
[src]
Get a tuple of the NodeIndex
es of the previous rounds that lead to one with the index id
, in the order (A, B)
pub fn winner(&self, id: NodeIndex) -> Result<Option<EntrantId>>
[src]
Get the EntrantId
of the solved winner of a particular round. Returns None
if the round hasn't been calculated yet, or if the node is a TournamentNode::Entrant
instead of a TournamentNode::Round
.
pub fn winner_entrant(&self, id: NodeIndex) -> Result<Option<Arc<RwLock<E>>>>
[src]
Identical to the winner()
function, but returns the Arc
<
RwLock
<E>>
encapsulating the entrant instead of its EntrantId
.
pub fn solve(&mut self) -> Result<()>
[src]
Solves all rounds in the tournament, as per solve_round()
, up to and including the returned by grand_finals()
pub fn solve_round(&mut self, id: NodeIndex) -> Result<TournamentRoundResult>
[src]
Solves rounds only up to the specified round.
Trait Implementations
impl<E: Debug + Display + Clone, M: Debug + Display + Clone + Default, B: Debug + BattleSystem<E, M>> Debug for Tournament<E, M, B>
[src]
impl<E: Debug + Display + Clone, M: Debug + Display + Clone + Default, B: BattleSystem<E, M>> Display for Tournament<E, M, B>
[src]
Auto Trait Implementations
impl<E, M, B> RefUnwindSafe for Tournament<E, M, B> where
B: RefUnwindSafe,
M: RefUnwindSafe,
B: RefUnwindSafe,
M: RefUnwindSafe,
impl<E, M, B> Send for Tournament<E, M, B> where
B: Send,
E: Send + Sync,
M: Send,
B: Send,
E: Send + Sync,
M: Send,
impl<E, M, B> Sync for Tournament<E, M, B> where
B: Sync,
E: Send + Sync,
M: Sync,
B: Sync,
E: Send + Sync,
M: Sync,
impl<E, M, B> Unpin for Tournament<E, M, B> where
B: Unpin,
M: Unpin,
B: Unpin,
M: Unpin,
impl<E, M, B> UnwindSafe for Tournament<E, M, B> where
B: UnwindSafe,
M: UnwindSafe,
B: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
fn get_type_id(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Event for T where
T: Send + Sync + 'static,
T: Send + Sync + 'static,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Resource for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,