Add debug
This commit is contained in:
parent
a2522ca44a
commit
a93c17711c
5 changed files with 13 additions and 13 deletions
|
|
@ -38,7 +38,7 @@ use crate::{
|
||||||
/// execution time permitted before it bails and falls back to an approximation.
|
/// execution time permitted before it bails and falls back to an approximation.
|
||||||
pub fn diff<T>(old: &[Token<T>], new: &[Token<T>]) -> Vec<RawOperation<T>>
|
pub fn diff<T>(old: &[Token<T>], new: &[Token<T>]) -> Vec<RawOperation<T>>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
let max_d = (old.len() + new.len()).div_ceil(2) + 1;
|
let max_d = (old.len() + new.len()).div_ceil(2) + 1;
|
||||||
let mut vb = V::new(max_d);
|
let mut vb = V::new(max_d);
|
||||||
|
|
@ -124,7 +124,7 @@ fn find_middle_snake<T>(
|
||||||
vb: &mut V,
|
vb: &mut V,
|
||||||
) -> Option<(usize, usize)>
|
) -> Option<(usize, usize)>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
let n = old_range.len();
|
let n = old_range.len();
|
||||||
let m = new_range.len();
|
let m = new_range.len();
|
||||||
|
|
@ -230,7 +230,7 @@ fn conquer<T>(
|
||||||
vb: &mut V,
|
vb: &mut V,
|
||||||
result: &mut Vec<RawOperation<T>>,
|
result: &mut Vec<RawOperation<T>>,
|
||||||
) where
|
) where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
// Check for common prefix
|
// Check for common prefix
|
||||||
let common_prefix_len = common_prefix_len(old, old_range.clone(), new, new_range.clone());
|
let common_prefix_len = common_prefix_len(old, old_range.clone(), new, new_range.clone());
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::tokenizer::token::Token;
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum RawOperation<T>
|
pub enum RawOperation<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
Insert(Vec<Token<T>>),
|
Insert(Vec<Token<T>>),
|
||||||
Delete(Vec<Token<T>>),
|
Delete(Vec<Token<T>>),
|
||||||
|
|
@ -12,7 +12,7 @@ where
|
||||||
|
|
||||||
impl<T> RawOperation<T>
|
impl<T> RawOperation<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
pub fn tokens(&self) -> &Vec<Token<T>> {
|
pub fn tokens(&self) -> &Vec<Token<T>> {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::operation_transformation::Operation;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MergeContext<T>
|
pub struct MergeContext<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
last_operation: Option<Operation<T>>,
|
last_operation: Option<Operation<T>>,
|
||||||
pub shift: i64,
|
pub shift: i64,
|
||||||
|
|
@ -13,7 +13,7 @@ where
|
||||||
|
|
||||||
impl<T> Default for MergeContext<T>
|
impl<T> Default for MergeContext<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
MergeContext {
|
MergeContext {
|
||||||
|
|
@ -25,7 +25,7 @@ where
|
||||||
|
|
||||||
impl<T> Debug for MergeContext<T>
|
impl<T> Debug for MergeContext<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("MergeContext")
|
f.debug_struct("MergeContext")
|
||||||
|
|
@ -37,7 +37,7 @@ where
|
||||||
|
|
||||||
impl<T> MergeContext<T>
|
impl<T> MergeContext<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
pub fn last_operation(&self) -> Option<&Operation<T>> { self.last_operation.as_ref() }
|
pub fn last_operation(&self) -> Option<&Operation<T>> { self.last_operation.as_ref() }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Token<T>
|
pub struct Token<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
normalised: T,
|
normalised: T,
|
||||||
original: String,
|
original: String,
|
||||||
|
|
@ -25,7 +25,7 @@ impl From<&str> for Token<String> {
|
||||||
|
|
||||||
impl<T> Token<T>
|
impl<T> Token<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
pub fn new(normalised: T, original: String) -> Self {
|
pub fn new(normalised: T, original: String) -> Self {
|
||||||
Token {
|
Token {
|
||||||
|
|
@ -43,7 +43,7 @@ where
|
||||||
|
|
||||||
impl<T> PartialEq for Token<T>
|
impl<T> PartialEq for Token<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
fn eq(&self, other: &Self) -> bool { self.normalised == other.normalised }
|
fn eq(&self, other: &Self) -> bool { self.normalised == other.normalised }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::operation_transformation::Operation;
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct OrderedOperation<T>
|
pub struct OrderedOperation<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone,
|
T: PartialEq + Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
pub order: usize,
|
pub order: usize,
|
||||||
pub operation: Operation<T>,
|
pub operation: Operation<T>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue