working on rust side

This commit is contained in:
2019-02-13 16:01:24 +01:00
parent 8c89b9c059
commit 3ee9533faf
4 changed files with 108 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ pub type DomainValues<'a, V> = Vec<&'a V>;
/// The domain of values that can be assigned to variables
#[derive(Clone)]
pub struct Domain<V> {
values: Vec<V>
pub values: Vec<V>
}
impl<V> Domain<V> {
@@ -51,6 +51,7 @@ impl<V> Domain<V> {
.filter(|v: &&V| filter_func(*v))
.collect()
}
}
impl<V: fmt::Debug> fmt::Debug for Domain<V> {
@@ -118,7 +119,12 @@ impl<'a,V, K: Eq + Hash + Clone> Problem<'a, V, K> {
{
let mut solutions: Vec<Variables<V, K>> = vec![];
let mut stack: Vec<Assignment<'a, V, K>> = vec![];
stack.append(&mut self._push_updates().unwrap());
if let Some(mut init_updates) = self._push_updates() {
stack.append(&mut init_updates);
} else {
panic!("Could not initialize !");
}
loop {
let node = stack.pop();
if node.is_none() { break; };
@@ -150,7 +156,12 @@ impl<'a,V, K: Eq + Hash + Clone> Problem<'a, V, K> {
K: Clone + fmt::Debug,
{
let mut stack: Vec<Assignment<'a, V, K>> = vec![];
stack.append(&mut self._push_updates().unwrap());
if let Some(mut init_updates) = self._push_updates() {
stack.append(&mut init_updates);
} else {
panic!("Could not initialize !");
}
loop {
let node = stack.pop();
if node.is_none() {