Skip to content

Commit c05ac18

Browse files
Replace MfCapacity with Integral from type traits
1 parent 51a9c98 commit c05ac18

File tree

2 files changed

+5
-49
lines changed

2 files changed

+5
-49
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) mod internal_type_traits;
2121
pub use dsu::Dsu;
2222
pub use fenwicktree::FenwickTree;
2323
pub use math::{crt, floor_sum, inv_mod, pow_mod};
24-
pub use maxflow::{Edge, MfCapacity, MfGraph};
24+
pub use maxflow::{Edge, MfGraph};
2525
pub use mincostflow::MinCostFlowGraph;
2626
pub use string::{
2727
lcp_array, lcp_array_arbitrary, suffix_array, suffix_array_arbitrary, suffix_array_manual,

src/maxflow.rs

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,12 @@
11
#![allow(dead_code)]
22
use crate::internal_queue::SimpleQueue;
3+
use crate::internal_type_traits::Integral;
34
use std::cmp::min;
45
use std::iter;
5-
use std::ops::{Add, AddAssign, Sub, SubAssign};
6-
7-
// Maybe it should be in a separate module
8-
pub trait MfCapacity:
9-
Copy + Ord + Add<Output = Self> + AddAssign + Sub<Output = Self> + SubAssign
10-
{
11-
fn zero() -> Self;
12-
fn max_value() -> Self;
13-
}
14-
15-
impl MfCapacity for i32 {
16-
fn zero() -> Self {
17-
0
18-
}
19-
fn max_value() -> Self {
20-
std::i32::MAX
21-
}
22-
}
23-
24-
impl MfCapacity for i64 {
25-
fn zero() -> Self {
26-
0
27-
}
28-
fn max_value() -> Self {
29-
std::i64::MAX
30-
}
31-
}
32-
33-
impl MfCapacity for u32 {
34-
fn zero() -> Self {
35-
0
36-
}
37-
fn max_value() -> Self {
38-
std::u32::MAX
39-
}
40-
}
41-
42-
impl MfCapacity for u64 {
43-
fn zero() -> Self {
44-
0
45-
}
46-
fn max_value() -> Self {
47-
std::u64::MAX
48-
}
49-
}
506

517
impl<Cap> MfGraph<Cap>
528
where
53-
Cap: MfCapacity,
9+
Cap: Integral,
5410
{
5511
pub fn new(n: usize) -> MfGraph<Cap> {
5612
MfGraph {
@@ -87,7 +43,7 @@ pub struct Edge<Cap> {
8743

8844
impl<Cap> MfGraph<Cap>
8945
where
90-
Cap: MfCapacity,
46+
Cap: Integral,
9147
{
9248
pub fn get_edge(&self, i: usize) -> Edge<Cap> {
9349
let m = self.pos.len();
@@ -200,7 +156,7 @@ struct FlowCalculator<'a, Cap> {
200156

201157
impl<Cap> FlowCalculator<'_, Cap>
202158
where
203-
Cap: MfCapacity,
159+
Cap: Integral,
204160
{
205161
fn bfs(&mut self) {
206162
self.level.iter_mut().for_each(|e| *e = -1);

0 commit comments

Comments
 (0)