i dies
This commit is contained in:
1 parent
9799c5af2f
commit
bfc7eab495
2 files changed
+30
-5
No files matched your search
@@ -1,3 +1,5 @@
|
|||||||
|
//! this file is pure brain fuck DO NOT read below code YOU HAVE BEEN WARNED
|
||||||
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
/// a vec like struct, where everything is ever increasing and not by anything more than one.
|
/// a vec like struct, where everything is ever increasing and not by anything more than one.
|
||||||
@@ -73,18 +75,36 @@ impl DB {
|
|||||||
} else if self.len() < *bro {
|
} else if self.len() < *bro {
|
||||||
panic!("run DB::verify_len(&self) ")
|
panic!("run DB::verify_len(&self) ")
|
||||||
}
|
}
|
||||||
self.len -= 1;
|
// self.len -= 1;
|
||||||
} else {
|
// }
|
||||||
|
// else {
|
||||||
|
}
|
||||||
// self.len.checked_sub(1);
|
// self.len.checked_sub(1);
|
||||||
self.len -= 1
|
self.len -= 1
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return returnvalue;
|
return returnvalue;
|
||||||
}
|
}
|
||||||
fn len(&self) -> u32 {
|
fn len(&self) -> u32 {
|
||||||
self.len
|
self.len
|
||||||
}
|
}
|
||||||
/// looks the same as [`DB::vec`](DB::vec)(&self).[`get`](core::slice::get)(ind as usize)
|
/**
|
||||||
|
get you know get it like its a traditional long ass vec
|
||||||
|
|
||||||
|
## useage:
|
||||||
|
```
|
||||||
|
# use lda_strdist::common_subsequence::db::DB;
|
||||||
|
# fn alterget(dp: &DB, ind: u32) {
|
||||||
|
DB::vec(dp).get(ind as usize);
|
||||||
|
# }
|
||||||
|
|
||||||
|
# fn main() {
|
||||||
|
let c = [0, 1, 1, 2, 3, 3, 3, 4, 4].to_vec();
|
||||||
|
let dp = DB::try_from_vec(c.clone()).expect("source vector with wrong form");
|
||||||
|
let ind = 5;
|
||||||
|
assert_eq!(DB::vec(&dp).get(ind as usize).cloned(), dp.get(ind));
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
*/
|
||||||
pub fn get(&self, ind: u32) -> Option<u32> {
|
pub fn get(&self, ind: u32) -> Option<u32> {
|
||||||
if self.len() <= ind {
|
if self.len() <= ind {
|
||||||
// panic!("index {ind} >= len {selflen} which is ugly")
|
// panic!("index {ind} >= len {selflen} which is ugly")
|
||||||
@@ -170,6 +190,7 @@ impl DB {
|
|||||||
(None, None)
|
(None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// result? change depend on up is not none
|
||||||
pub fn change(&mut self, ind: u32, val: u32) {
|
pub fn change(&mut self, ind: u32, val: u32) {
|
||||||
let (avail, up) = self.available_values(ind);
|
let (avail, up) = self.available_values(ind);
|
||||||
if let (Some(avail), Some(up)) = (avail, up) {
|
if let (Some(avail), Some(up)) = (avail, up) {
|
||||||
@@ -199,6 +220,7 @@ impl DB {
|
|||||||
if self.len() > 0 {
|
if self.len() > 0 {
|
||||||
if matches!(self.last(), Some(x) if (x) > 0) {
|
if matches!(self.last(), Some(x) if (x) > 0) {
|
||||||
match self.get(ind) {
|
match self.get(ind) {
|
||||||
|
// what is this fucking logic idk man what the fuck is this code
|
||||||
Some(vecv) if vecv == val => {
|
Some(vecv) if vecv == val => {
|
||||||
self.inner.truncate(val as usize);
|
self.inner.truncate(val as usize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use db::DB;
|
use db::DB;
|
||||||
|
|
||||||
mod db;
|
pub mod db;
|
||||||
|
|
||||||
pub fn lcs_gen(str1: &str, str2: &str) -> Vec<Vec<u32>> {
|
pub fn lcs_gen(str1: &str, str2: &str) -> Vec<Vec<u32>> {
|
||||||
let c1: Vec<char> = str1.chars().collect();
|
let c1: Vec<char> = str1.chars().collect();
|
||||||
@@ -62,6 +62,9 @@ pub fn lcs_gen_db(str1: &str, str2: &str) -> Vec<DB> {
|
|||||||
db
|
db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user