patch_rs/context/merge.rs
1//!
2//! The context merging algorithm.
3//!
4
5//use std::collections::VecDeque;
6//
7//use log::*;
8//
9//use crate::{
10// context::{Context, ContextHeader},
11// line::Line,
12//};
13//
14//impl Context {
15// pub fn merge(self, other: Self) -> Self {
16// let (mut first, mut second) = if self.header.file1_l <= other.header.file1_l {
17// (self, other)
18// } else {
19// (other, self)
20// };
21// if first.header.file1_l + first.header.file1_s < second.header.file1_l {
22// panic!("ERROR 1");
23// }
24//
25// trace!("Element 1: \n{}", first);
26// trace!("Element 2: \n{}", second);
27//
28// let mut sum = first.clone();
29// for i in 0..second.size() {
30// let index = second.header.file1_l;
31// if let Some(line) = second.pop_front() {
32// let shift = sum.insert(line, index);
33// second.shift(shift);
34// trace!("Intermediate: \n{}", sum);
35// }
36// }
37// sum
38// }
39//}