当前位置: 首页>>代码示例>>C++>>正文


C++ Alphabet::push_back方法代码示例

本文整理汇总了C++中Alphabet::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Alphabet::push_back方法的具体用法?C++ Alphabet::push_back怎么用?C++ Alphabet::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alphabet的用法示例。


在下文中一共展示了Alphabet::push_back方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testOperatorNotEqual

void ComposedElementTest::testOperatorNotEqual() {

	// initializes alphabet	
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);

	// initializes elements
	Element elementH(*hydrogen);
	Element elementO(*oxygen);
	Element elementC(*carbon);
	
	elements_container elements;
	elements[elementH] = 4;
	elements[elementO] = 2;
	elements[elementC] = 2;
			
	// checks case with different elements
	composed_element_type molecule1(elements);
	elements[elementH] = 5;
	composed_element_type molecule1_not_equal(elements);
	
	CPPUNIT_ASSERT(molecule1 != molecule1_not_equal);
		
	// checks case with different sequences
	composed_element_type molecule3("C2H4O2", cho),
						molecule3_not_equal("C2H3O2", cho);
	CPPUNIT_ASSERT(molecule3 != molecule3_not_equal);
		
}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:31,代码来源:composedelementtest.cpp

示例2: testOperatorMinus

void ComposedElementTest::testOperatorMinus() {

	// initializes alphabet	
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);
		
	composed_element_type molecule1("H10O6", cho), molecule2("O4H4", cho);

	molecule1 -= molecule2;

	CPPUNIT_ASSERT_EQUAL(molecule1.getElements().size(), 
				static_cast<elements_container::size_type>(2));
	CPPUNIT_ASSERT_EQUAL(molecule1.getElementAbundance("O"), 
				static_cast<elements_container::mapped_type>(2));
	CPPUNIT_ASSERT_EQUAL(molecule1.getElementAbundance("H"), 
				static_cast<elements_container::mapped_type>(6));
	
	composed_element_type molecule3("O8H2", cho), molecule4("O6H7C5", cho);

	molecule3 -= molecule4;

	CPPUNIT_ASSERT_EQUAL(molecule3.getElements().size(), 
				static_cast<elements_container::size_type>(1));
	CPPUNIT_ASSERT_EQUAL(molecule3.getElementAbundance("O"), 
				static_cast<elements_container::mapped_type>(2));
}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:28,代码来源:composedelementtest.cpp

示例3: testOperatorEqual

void ComposedElementTest::testOperatorEqual() {

	// checks for type of constructors with sequence	
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);
	
	composed_element_type molecule1("H4C2O2", cho);
	
	composed_element_type molecule1_equal("H4C2O2", cho);

	CPPUNIT_ASSERT(molecule1 == molecule1_equal);	
	
	// checks for type of constructors with elements
	Element elementH(*hydrogen);
	Element elementO(*oxygen);
	Element elementC(*carbon);
	
	elements_container elements;
	elements[elementH] = 4;
	elements[elementO] = 2;
	elements[elementC] = 2;
	
	// checks for type of constructors with elements and random sequence order
	composed_element_type molecule2(elements);
	
	composed_element_type molecule2_equal(elements);

	CPPUNIT_ASSERT(molecule2 == molecule2_equal);		

}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:32,代码来源:composedelementtest.cpp

示例4: testUpdateIsotopeDistribution

void ComposedElementTest::testUpdateIsotopeDistribution() {
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);

	std::vector<unsigned int> decomposition;
	decomposition.push_back(static_cast<unsigned int>(4));
	decomposition.push_back(static_cast<unsigned int>(2));
	decomposition.push_back(static_cast<unsigned int>(2));
	
	// initializes molecule without setting isotope distribution and sequence
	composed_element_type molecule(decomposition, cho);

	molecule.updateIsotopeDistribution();

	isotopes_type isodistr = molecule.getIsotopeDistribution();

	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getMass(0), static_cast<mass_type>(60.02113), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getMass(1), static_cast<mass_type>(61.0245862), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getMass(2), static_cast<mass_type>(62.0254827), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getMass(3), static_cast<mass_type>(63.0288285), 1.0e-6);

	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getAbundance(0), static_cast<abundance_type>(0.972690002), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getAbundance(1), static_cast<abundance_type>(0.0231608083), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getAbundance(2), static_cast<abundance_type>(0.00405304857), 1.0e-6);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(isodistr.getAbundance(3), static_cast<abundance_type>(9.1561898e-05), 1.0e-6);

}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:29,代码来源:composedelementtest.cpp

示例5: testConstructorDecompositionAlphabet

void ComposedElementTest::testConstructorDecompositionAlphabet() {
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);

	std::vector<unsigned int> decomposition;
	decomposition.push_back(static_cast<unsigned int>(3));
	decomposition.push_back(static_cast<unsigned int>(2));
	decomposition.push_back(static_cast<unsigned int>(1));

	composed_element_type molecule(decomposition, cho);

	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("C"), 
							static_cast<elements_container::mapped_type>(2));
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("H"), 
							static_cast<elements_container::mapped_type>(3));							
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("O"), 
							static_cast<elements_container::mapped_type>(1));	

	// checks if isotope distribution is not yet initialized
	CPPUNIT_ASSERT(molecule.getIsotopeDistribution().empty());
	// checks if sequence is not yet initialized
	CPPUNIT_ASSERT(molecule.getSequence().empty());
}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:25,代码来源:composedelementtest.cpp

示例6: testConstructorTexNotationSequenceAlphabet

void ComposedElementTest::testConstructorTexNotationSequenceAlphabet() {
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);
	
	composed_element_type molecule("C_{2}H_{4}O_{2}", cho, composed_element_type::TEX_NOTATION_MOLECULE_SEQUENCE_TYPE);
	CPPUNIT_ASSERT_EQUAL(molecule.getSequence(), static_cast<name_type>("C_{2}H_{4}O_{2}"));	
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("C"), 
							static_cast<elements_container::mapped_type>(2));
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("H"), 
							static_cast<elements_container::mapped_type>(4));		
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("O"), 
							static_cast<elements_container::mapped_type>(2));	
	// checks if isotope distribution is not yet initialized
	CPPUNIT_ASSERT(molecule.getIsotopeDistribution().empty());							
}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:17,代码来源:composedelementtest.cpp

示例7: testConstructorSequenceAlphabet

void ComposedElementTest::testConstructorSequenceAlphabet() {
	Alphabet cho;
	cho.push_back(*hydrogen);
	cho.push_back(*carbon);
	cho.push_back(*oxygen);
	
	composed_element_type molecule("C2H4O2", cho);
	CPPUNIT_ASSERT_EQUAL(molecule.getSequence(), static_cast<name_type>("C2H4O2"));	
	CPPUNIT_ASSERT_EQUAL(molecule.getElements().size(), 
				static_cast<elements_container::size_type>(3));
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("C"), 
							static_cast<elements_container::mapped_type>(2));
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("H"), 
							static_cast<elements_container::mapped_type>(4));		
	CPPUNIT_ASSERT_EQUAL(molecule.getElementAbundance("O"), 
							static_cast<elements_container::mapped_type>(2));	
	// checks if isotope distribution is not yet initialized
	CPPUNIT_ASSERT(molecule.getIsotopeDistribution().empty());							
}
开发者ID:nathaniel-mahieu,项目名称:Rdisop,代码行数:19,代码来源:composedelementtest.cpp


注:本文中的Alphabet::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。