Added clear() and empty() to TupleConfig
							parent
							
								
									bc3032b9a0
								
							
						
					
					
						commit
						7c2ad06016
					
				| 
						 | 
				
			
			@ -128,6 +128,9 @@ namespace gtsam {
 | 
			
		|||
	  void erase(const Key& j)  { second_.erase(j); }
 | 
			
		||||
	  void erase(const Key1& j)  { first_.erase(j); }
 | 
			
		||||
 | 
			
		||||
	  /** clears the config */
 | 
			
		||||
	  void clear() { first_.clear(); second_.clear(); }
 | 
			
		||||
 | 
			
		||||
	  /** determine whether an element exists */
 | 
			
		||||
	  template<class Key>
 | 
			
		||||
	  bool exists(const Key& j) const { return second_.exists(j); }
 | 
			
		||||
| 
						 | 
				
			
			@ -162,6 +165,9 @@ namespace gtsam {
 | 
			
		|||
	  /** @return number of key/value pairs stored */
 | 
			
		||||
	  size_t size() const { return first_.size() + second_.size(); }
 | 
			
		||||
 | 
			
		||||
	  /** @return true if config is empty */
 | 
			
		||||
	  bool empty() const { return first_.empty() && second_.empty(); }
 | 
			
		||||
 | 
			
		||||
	  /** @return The dimensionality of the tangent space */
 | 
			
		||||
	  size_t dim() const { return first_.dim() + second_.dim(); }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -241,6 +247,10 @@ namespace gtsam {
 | 
			
		|||
 | 
			
		||||
	  void erase(const Key1& j) { first_.erase(j); }
 | 
			
		||||
 | 
			
		||||
	  void clear() { first_.clear(); }
 | 
			
		||||
 | 
			
		||||
	  bool empty() const { return first_.empty(); }
 | 
			
		||||
 | 
			
		||||
	  bool exists(const Key1& j) const { return first_.exists(j); }
 | 
			
		||||
 | 
			
		||||
	  boost::optional<Value1> exists_(const Key1& j) const { return first_.exists_(j); }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ TEST( TupleConfig, insert_equals2 )
 | 
			
		|||
  CHECK(!config1.equals(config2));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
///* ************************************************************************* */
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
TEST( TupleConfig, insert_duplicate )
 | 
			
		||||
{
 | 
			
		||||
  Pose2 x1(1,2,3), x2(6,7,8);
 | 
			
		||||
| 
						 | 
				
			
			@ -271,6 +271,16 @@ TEST(TupleConfig, basic_functions) {
 | 
			
		|||
	configB.erase(L1);
 | 
			
		||||
	CHECK(!configB.exists(L1));
 | 
			
		||||
	CHECK(configB.size() == 2);
 | 
			
		||||
 | 
			
		||||
	// clear
 | 
			
		||||
	configA.clear();
 | 
			
		||||
	CHECK(configA.size() == 0);
 | 
			
		||||
	configB.clear();
 | 
			
		||||
	CHECK(configB.size() == 0);
 | 
			
		||||
 | 
			
		||||
	// empty
 | 
			
		||||
	CHECK(configA.empty());
 | 
			
		||||
	CHECK(configB.empty());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue