aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2020-11-23 13:26:20 +0200
committerIgor Pashev <pashev.igor@gmail.com>2020-11-23 13:26:20 +0200
commitb488d946cf1a1572000ab3e7137946c3d2e9cb32 (patch)
tree4031522a8c3e2819403e7662c4d199b5bc1dc7e2
parenta955c01d1b4449457dbd24de6b69db8ccac8f04c (diff)
downloadfrotate.rs-b488d946cf1a1572000ab3e7137946c3d2e9cb32.tar.gz
Use explicit starting point
-rw-r--r--src/partition.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/partition.rs b/src/partition.rs
index 46efeac..3f2837d 100644
--- a/src/partition.rs
+++ b/src/partition.rs
@@ -41,7 +41,7 @@ mod tests {
list![9]
];
- assert_eq!(partition(&|_n| 1, &ins), outs);
+ assert_eq!(partition(&|_n| 1, ins[0], &ins), outs);
}
#[test]
@@ -49,7 +49,7 @@ mod tests {
let ins = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
let outs = list![list![1, 2], list![3, 4], list![5, 6], list![7, 8], list![9]];
- assert_eq!(partition(&|_n| 2, &ins), outs);
+ assert_eq!(partition(&|_n| 2, ins[0], &ins), outs);
}
#[test]
@@ -73,7 +73,7 @@ mod tests {
list![15]
];
- assert_eq!(partition(&|_n| 1, &ins), outs);
+ assert_eq!(partition(&|_n| 1, ins[0], &ins), outs);
}
#[test]
@@ -90,7 +90,7 @@ mod tests {
list![15]
];
- assert_eq!(partition(&|_n| 2, &ins), outs);
+ assert_eq!(partition(&|_n| 2, ins[0], &ins), outs);
}
fn exp2(n: u32) -> i64 {
@@ -108,7 +108,7 @@ mod tests {
list![8, 9, 10, 11, 12, 13]
];
- assert_eq!(partition(&exp2, &ins), outs);
+ assert_eq!(partition(&exp2, ins[0], &ins), outs);
}
#[test]
@@ -132,11 +132,11 @@ mod tests {
}
}
-pub fn partition(f: &dyn Fn(u32) -> i64, v: &[i64]) -> LinkedList<LinkedList<i64>> {
+pub fn partition(f: &dyn Fn(u32) -> i64, v0: i64, v: &[i64]) -> LinkedList<LinkedList<i64>> {
let mut term: LinkedList<i64> = LinkedList::new();
let mut res: LinkedList<LinkedList<i64>> = LinkedList::new();
let mut n: u32 = 1;
- let mut a: i64 = v[0];
+ let mut a: i64 = v0;
for &i in v.iter() {
while i >= a + f(n) {
@@ -168,7 +168,7 @@ pub fn partition_days(
v.sort_unstable();
v.dedup();
- part = partition(f, &v);
+ part = partition(f, v[0], &v);
}
part.into_iter()