@@ -25,10 +25,17 @@ pub trait UnificationStore: ops::Index<usize, Output = VarValue<Key<Self>>> + Cl
2525
2626 fn commit ( & mut self , snapshot : Self :: Snapshot ) ;
2727
28+ fn reset_unifications (
29+ & mut self ,
30+ value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ,
31+ ) ;
32+
2833 fn len ( & self ) -> usize ;
2934
3035 fn push ( & mut self , value : VarValue < Self :: Key > ) ;
3136
37+ fn reserve ( & mut self , num_new_values : usize ) ;
38+
3239 fn update < F > ( & mut self , index : usize , op : F )
3340 where F : FnOnce ( & mut VarValue < Self :: Key > ) ;
3441
@@ -69,6 +76,14 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
6976 self . values . commit ( snapshot) ;
7077 }
7178
79+ #[ inline]
80+ fn reset_unifications (
81+ & mut self ,
82+ mut value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ,
83+ ) {
84+ self . values . set_all ( |i| value ( i as u32 ) ) ;
85+ }
86+
7287 #[ inline]
7388 fn len ( & self ) -> usize {
7489 self . values . len ( )
@@ -79,6 +94,11 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
7994 self . values . push ( value) ;
8095 }
8196
97+ #[ inline]
98+ fn reserve ( & mut self , num_new_values : usize ) {
99+ self . values . reserve ( num_new_values) ;
100+ }
101+
82102 #[ inline]
83103 fn update < F > ( & mut self , index : usize , op : F )
84104 where F : FnOnce ( & mut VarValue < Self :: Key > )
@@ -137,6 +157,19 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
137157 fn commit ( & mut self , _snapshot : Self :: Snapshot ) {
138158 }
139159
160+ #[ inline]
161+ fn reset_unifications (
162+ & mut self ,
163+ mut value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ,
164+ ) {
165+ // Without extending dogged, there isn't obviously a more
166+ // efficient way to do this. But it's pretty dumb. Maybe
167+ // dogged needs a `map`.
168+ for i in 0 .. self . values . len ( ) {
169+ self . values [ i] = value ( i as u32 ) ;
170+ }
171+ }
172+
140173 #[ inline]
141174 fn len ( & self ) -> usize {
142175 self . values . len ( )
@@ -147,6 +180,11 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
147180 self . values . push ( value) ;
148181 }
149182
183+ #[ inline]
184+ fn reserve ( & mut self , _num_new_values : usize ) {
185+ // not obviously relevant to DVec.
186+ }
187+
150188 #[ inline]
151189 fn update < F > ( & mut self , index : usize , op : F )
152190 where F : FnOnce ( & mut VarValue < Self :: Key > )
0 commit comments