Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created June 5, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BruJu/6344dfa0229173be66fec2ce75a44fa5 to your computer and use it in GitHub Desktop.
Save BruJu/6344dfa0229173be66fec2ce75a44fa5 to your computer and use it in GitHub Desktop.
TreedDataset - new with same indexes
// At the moment, this code feels bad to write and seems unnecessary
// but it may not be that bad so I keep it here
// https://github.com/BruJu/Portable-Reasoning-in-Web-Assembly
// https://github.com/BruJu/WasmTreeDataset
impl TreedDataset {
pub fn new_with_same_indexes(&self) -> Self {
let base_index = vec!(self.base_tree.0.clone());
let optional_indexes = {
let mut vec = vec!();
for optional in (&self.optional_trees).into_iter() {
vec.push(optional.0);
}
vec
};
TreedDataset::new_with_blocks(base_index, optional_indexes)
// To copy the elements
// new_tree.base_tree.1 = (&self.base_tree.1).into_iter().map(|element| element.clone()).collect();
}
@BruJu
Copy link
Author

BruJu commented Jun 5, 2020

There is probably a way to improve the data structure. I think the block / block order abstraction is nice to hide the quad terms reordering but the way the TreedDataset manipulates the subtrees is weird.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment