File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -186,14 +186,29 @@ namespace geode
186186 public:
187187 void map ( const T1& in, const T2& out )
188188 {
189+ if ( this ->has_mapping_input ( in ) )
190+ {
191+ if ( absl::c_contains ( this ->in2out_mapping ().at ( in ), out ) )
192+ {
193+ return ;
194+ }
195+ }
189196 this ->in2out_mapping ()[in].push_back ( out );
190197 this ->out2in_mapping ()[out].push_back ( in );
191198 }
192199
193200 void unmap ( const T1& in, const T2& out )
194201 {
202+ if ( !this ->has_mapping_input ( in ) )
203+ {
204+ return ;
205+ }
195206 auto & in_map = this ->in2out_mapping ().at ( in );
196207 const auto itr = absl::c_find ( in_map, out );
208+ if ( itr == in_map.end () )
209+ {
210+ return ;
211+ }
197212 in_map.erase ( itr );
198213 if ( this ->in2out ( in ).empty () )
199214 {
Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ void test_generic_mappings()
108108 generic.map ( 0 , -8.0 );
109109 generic.map ( 0 , -8.0 );
110110 generic.map ( 5 , -8.0 );
111- OPENGEODE_EXCEPTION ( generic.out2in ( -8.0 ).size () == 5 ,
112- " [Test] Size of out2in for -8.0 should be 5 " );
111+ OPENGEODE_EXCEPTION ( generic.out2in ( -8.0 ).size () == 2 ,
112+ " [Test] Size of out2in for -8.0 should be 2 " );
113113 generic.erase_in ( 0 );
114114 OPENGEODE_EXCEPTION ( generic.out2in ( -8.0 ).size () == 1 ,
115115 " [Test] Size of out2in for -8.0 should be 1" );
You can’t perform that action at this time.
0 commit comments