elementcomparisonfunctions.cpp

来自「最新官方例子,图形,描述副,基本控件,通讯协议,等等,」· C++ 代码 · 共 67 行

CPP
67
字号
/**
*
* @brief Namespace to encapsulate comparison and equality functions for RArray sorting and finding
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "elementcomparisonfunctions.h"

// User includes
#include "chemicalelement.h"

// ================= MEMBER FUNCTIONS =======================

//Equality functions
TBool NElementComparisonFunctions::ElementsHaveSameName(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	return aElement1.Name() == aElement2.Name();
	}

TBool NElementComparisonFunctions::ElementsHaveSameSymbol(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	return aElement1.Symbol() == aElement2.Symbol();
	}

TBool NElementComparisonFunctions::ElementsHaveSameAtomicNumber(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	return aElement1.AtomicNumber() == aElement2.AtomicNumber();
	}

//Comparison functions
TInt NElementComparisonFunctions::CompareElementsName(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	return aElement1.Name().CompareF(aElement2.Name());
	}

TInt NElementComparisonFunctions::CompareElementsSymbol(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	return aElement1.Symbol().CompareF(aElement2.Symbol());
	}

TInt NElementComparisonFunctions::CompareElementsAtomicNumber(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	if (aElement1.AtomicNumber() == aElement2.AtomicNumber())
		{
		return 0;
		}

	return aElement1.AtomicNumber() < aElement2.AtomicNumber() ? -1 : 1;
	}

TInt NElementComparisonFunctions::CompareElementsRelativeAtomicMass(const CChemicalElement& aElement1, const CChemicalElement& aElement2)
	{
	if (aElement1.RelativeAtomicMass() == aElement2.RelativeAtomicMass())
		{
		return 0;
		}

	return aElement1.RelativeAtomicMass() < aElement2.RelativeAtomicMass() ? -1 : 1;
	}

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?