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


C++ Bool类代码示例

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


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

示例1: Beagle_RunTimeExceptionM

/*!
 *  \brief Evaluate the individual fitness for the spambase problem.
 *  \param inIndividual Individual to evaluate.
 *  \param ioContext Evolutionary context.
 *  \return Handle to the fitness measure,
 */
Fitness::Handle SpambaseEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
	// Get reference to data set
	DataSetClassification::Handle lDataSet =
	    castHandleT<DataSetClassification>(ioContext.getSystem().getComponent("DataSet"));
	if(lDataSet == NULL) {
		throw Beagle_RunTimeExceptionM("Data set is not present in the system, could not proceed further!");
	}

	// Generate indices used as data subset for fitness evaluation
	std::vector<unsigned int> lSubSet(lDataSet->size());
	for(unsigned int i=0; i<lSubSet.size(); ++i) lSubSet[i] = i;
	std::random_shuffle(lSubSet.begin(), lSubSet.end(),
	                    ioContext.getSystem().getRandomizer());
	if(Spambase_TestSize < lSubSet.size()) {
		lSubSet.resize(Spambase_TestSize);
	}

	// Evaluate sampled test cases
	unsigned int lCorrectCount = 0;
	for(unsigned int i=0; i<Spambase_TestSize; ++i) {
		const bool lPositiveID = ((*lDataSet)[lSubSet[i]].first == 1);
		const Beagle::Vector& lData = (*lDataSet)[lSubSet[i]].second;
		for(unsigned int j=0; j<lData.size(); ++j) {
			std::ostringstream lOSS;
			lOSS << "IN" << j;
			setValue(lOSS.str(), Double(lData[j]), ioContext);
		}
		Bool lResult;
		inIndividual.run(lResult, ioContext);
		if(lResult.getWrappedValue() == lPositiveID) ++lCorrectCount;
	}
	double lFitness = double(lCorrectCount) / Spambase_TestSize;
	return new EC::FitnessSimple(lFitness);
}
开发者ID:GhostGambler,项目名称:beagle,代码行数:41,代码来源:SpambaseEvalOp.cpp

示例2: dataType

void
CIMQualifierType::readObject(istream &istrm)
{
	CIMName name;
	CIMDataType dataType(CIMNULL);
	CIMScopeArray scope;
	CIMFlavorArray flavor;
	CIMValue defaultValue(CIMNULL);
	CIMBase::readSig( istrm, OW_CIMQUALIFIERTYPESIG );
	name.readObject(istrm);
	dataType.readObject(istrm);
	BinarySerialization::readArray(istrm, scope);
	BinarySerialization::readArray(istrm, flavor);
	Bool isValue;
	isValue.readObject(istrm);
	if (isValue)
	{
		defaultValue.readObject(istrm);
	}
	if (!m_pdata)
	{
		m_pdata = new QUALTData;
	}
	m_pdata->m_name = name;
	m_pdata->m_dataType = dataType;
	m_pdata->m_scope = scope;
	m_pdata->m_flavor = flavor;
	m_pdata->m_defaultValue = defaultValue;
}
开发者ID:kkaempf,项目名称:openwbem,代码行数:29,代码来源:OW_CIMQualifierType.cpp

示例3: readBool

	inline Bool readBool(std::istream& istrm)
	{
		BinarySerialization::verifySignature(istrm, BINSIG_BOOL);
		Bool b;
		b.readObject(istrm);
		return b;
	}
开发者ID:kkaempf,项目名称:openwbem,代码行数:7,代码来源:OW_BinarySerialization.hpp

示例4: not_has_element

Bool* not_has_element(Variable* A, Variable* B)
{
    Bool* b = has_element(A, B);
    if(b == NULL)
        return NULL;
    b->setValue(!b->getValue());
    return b;
}
开发者ID:TheProjecter,项目名称:pile-build,代码行数:8,代码来源:eve_operators.cpp

示例5: TEST

TEST(VersionTest, InitWithVarRequiringCast) {
    Bool a = any_bool("A");
    Char b = any_char("B");
    Int c = b;

    EXPECT_EQ(0, a.get_version());
    EXPECT_EQ(0, b.get_version());
    EXPECT_EQ(0, c.get_version());
}
开发者ID:baptist,项目名称:libse,代码行数:9,代码来源:version_test.cpp

示例6: GetBool

//-----------------------------------------------------------------------------
bool DataType::GetBool() const
{
    HRESULT hr;
    Bool b;
    
    hr = b.Cast( *this );
    if( FAILED(hr) )
        return 0;

    return b.Get();
}
开发者ID:Edenspuzzle,项目名称:EdensEngine,代码行数:12,代码来源:DataType.cpp

示例7: has_element

Bool* has_element(Variable* A, Variable* B)
{
    if(A == NULL || B == NULL)
    {
        interpreter.error("Error: Void variable in has_element operation.\n");
        return NULL;
    }
    TypeEnum a = A->getType();
    TypeEnum b = B->getType();
    if(a != ARRAY && b != ARRAY)
    {
        interpreter.error("Error: Has_element not defined for types '%s' and '%s'\n", getTypeString(a).c_str(), getTypeString(b).c_str());
        return NULL;
    }

    Array* C;
    Variable* other;
    TypeEnum otherType;
    if(a == ARRAY)
    {
        C = static_cast<Array*>(A);
        other = B;
        otherType = b;
    }
    else
    {
        C = static_cast<Array*>(B);
        other = A;
        otherType = a;
    }

    if(otherType != C->getValueType())
    {
        interpreter.error("Error: Has_element not defined for types '%s' and '%s'\n", getTypeString(ARRAY).c_str(), getTypeString(otherType).c_str());
        return NULL;
    }

    vector<Variable*>& v = C->getValue();
    for(vector<Variable*>::iterator e = v.begin(); e != v.end(); e++)
    {
        Bool* test = comparison(other, *e, EQUALS);
        if(test->getValue() == true)
            return test;
        delete test;
    }

    return new Bool(false);
}
开发者ID:TheProjecter,项目名称:pile-build,代码行数:48,代码来源:eve_operators.cpp

示例8: return

mxLogical *mxGetLogicals(const mxArray *ptr)
{
    InternalType *pIT = (InternalType *)ptr;
    if (pIT == NULL)
    {
        return NULL;
    }

    Bool *pB = pIT->getAs<Bool>();
    if (pB == NULL)
    {
        return NULL;
    }

    return (mxLogical *)pB->get();
}
开发者ID:scitao,项目名称:scilab,代码行数:16,代码来源:mexlib.cpp

示例9: uint2str

/*!
 *  \brief Evaluate the individual fitness for the even-6 parity problem.
 *  \param inIndividual Individual to evaluate.
 *  \param ioContext Evolutionary context.
 *  \return Handle to the fitness measure,
 */
Fitness::Handle ParityEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
	unsigned int lGood = 0;
	for(unsigned int i=0; i<ParitySizeM; i++) {
		for(unsigned int j=0; j<ParityFanInM; j++) {
			std::string lName = "IN";
			lName += uint2str(j);
			setValue(lName, mInputs[i][j], ioContext);
		}
		Bool lResult;
		inIndividual.run(lResult, ioContext);
		if(lResult.getWrappedValue() == mOutputs[i].getWrappedValue()) lGood++;
	}
	double lFitness = double(lGood) / ParitySizeM;
	return new FitnessSimple(lFitness);
}
开发者ID:splodginald,项目名称:MPI-PACC-OpenBeagle,代码行数:22,代码来源:ParityEvalOp.cpp

示例10: switch

Bool *Bool::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
    Bool *result = nullptr;
    switch (constructor) {
        case 0x997275b5:
            result = new TL_boolTrue();
            break;
        case 0xbc799737:
            result = new TL_boolFalse();
            break;
        default:
            error = true;
            DEBUG_E("can't parse magic %x in Bool", constructor);
            return nullptr;
    }
    result->readParams(stream, instanceNum, error);
    return result;
}
开发者ID:acc11311,项目名称:Telegram,代码行数:17,代码来源:ApiScheme.cpp

示例11: setValue

/*!
 *  \brief Evaluate the individual fitness for the boolean 11-multiplexer problem.
 *  \param inIndividual Individual to evaluate.
 *  \param ioContext Evolutionary context.
 *  \return Handle to the fitness measure,
 */
Fitness::Handle MultiplexerEvalOp::evaluate(GP::Individual& inIndividual, GP::Context& ioContext)
{
	unsigned int lNbGood = 0;
	for(unsigned int i=0; i<2048; ++i) {
		setValue("A0", mInputs[i][0], ioContext);
		setValue("A1", mInputs[i][1], ioContext);
		setValue("A2", mInputs[i][2], ioContext);
		setValue("D0", mInputs[i][3], ioContext);
		setValue("D1", mInputs[i][4], ioContext);
		setValue("D2", mInputs[i][5], ioContext);
		setValue("D3", mInputs[i][6], ioContext);
		setValue("D4", mInputs[i][7], ioContext);
		setValue("D5", mInputs[i][8], ioContext);
		setValue("D6", mInputs[i][9], ioContext);
		setValue("D7", mInputs[i][10], ioContext);
		Bool lResult;
		inIndividual.run(lResult, ioContext);
		if(lResult.getWrappedValue() == mOutputs[i].getWrappedValue()) ++lNbGood;
	}
	double lFitness = double(lNbGood) / 2048.;
	return new EC::FitnessSimple(lFitness);
}
开发者ID:GhostGambler,项目名称:beagle,代码行数:28,代码来源:MultiplexerEvalOp.cpp

示例12: outValue

void BoolAttribute::onSettingSpecialization(const std::vector<std::string> &specialization) {
    Bool *boolVal = outValue();

    boolVal->setIsArray(false);
    if(boolVal->size() == 0) {
        boolVal->resize(1);
        boolVal->setBoolValueAt(0, false);
    }

    if(specialization.size() == 1) {
        if(specialization[0] == "BoolArray") {
            boolVal->setIsArray(true);
        }
    }
}
开发者ID:gootokuzi,项目名称:coral-repo,代码行数:15,代码来源:BoolAttribute.cpp

示例13: value

std::string BoolAttribute::shortDebugInfo() {
    std::string info = Attribute::shortDebugInfo() + "\n";

    Bool *val = value();
    int slices = val->slices();

    bool isArray = val->isArray();

    info += "slices: " + stringUtils::intToString(slices) + "\n";
    for(int i = 0; i < val->slices(); ++i) {
        info += "slice: " + 	stringUtils::intToString(i) + ", ";
        if(isArray) {
            info += "size: " + stringUtils::intToString(val->sizeSlice(i)) + ", ";
        }

        std::string valStr = val->sliceAsString(i);
        std::vector<std::string> split;
        stringUtils::split(valStr, split, " ");
        valStr = split[0];

        std::string trimmedValStr;
        if(valStr.size() < 100) {
            trimmedValStr = valStr;
        }
        else {
            for(int i = 0; i < 100; ++i) {
                trimmedValStr += valStr[i];
            }
            trimmedValStr += " ...]";
        }

        info += trimmedValStr + "\n";

        if(i > 3) {
            info += "(trimming remaining slices)\n";
            break;
        }
    }

    return info;
}
开发者ID:gootokuzi,项目名称:coral-repo,代码行数:41,代码来源:BoolAttribute.cpp

示例14: comparison

Bool* comparison(Variable* A, Variable* B, OperatorEnum oper)
{
    if(A == NULL || B == NULL)
    {
        interpreter.error("Error: Void variable in assignment.\n");
        return NULL;
    }
    TypeEnum a = A->getType();
    TypeEnum b = B->getType();


    bool mismatch = false;
    if(a == STRING)
    {
        if(b != STRING)
            mismatch = true;
        else
        {
            String* C = static_cast<String*>(A);
            String* D = static_cast<String*>(B);
            switch(oper)
            {
                case EQUALS:
                    return new Bool(C->getValue() == D->getValue());
                case NOT_GREATER:
                case LESS_EQUAL:
                    return new Bool(C->getValue() <= D->getValue());
                case NOT_LESS:
                case GREATER_EQUAL:
                    return new Bool(C->getValue() >= D->getValue());
                case LESS:
                    return new Bool(C->getValue() < D->getValue());
                case GREATER:
                    return new Bool(C->getValue() > D->getValue());
                case NOT_EQUALS:
                    return new Bool(C->getValue() != D->getValue());
                default:
                    UI_debug_pile("Pile Error: Bad operator passed to comparison().\n");
                    return NULL;
            }
        }
    }
    else if(a == INT)
    {
        if(b != BOOL && b != INT && b != FLOAT)
            mismatch = true;
        else
        {
            Int* C = static_cast<Int*>(A);
            if(b == BOOL)
            {
                Bool* D = static_cast<Bool*>(B);
                switch(oper)
                {
                    case EQUALS:
                        return new Bool(C->getValue() == D->getValue());
                    case NOT_GREATER:
                    case LESS_EQUAL:
                        return new Bool(C->getValue() <= D->getValue());
                    case NOT_LESS:
                    case GREATER_EQUAL:
                        return new Bool(C->getValue() >= D->getValue());
                    case LESS:
                        return new Bool(C->getValue() < D->getValue());
                    case GREATER:
                        return new Bool(C->getValue() > D->getValue());
                    case AND:
                        return new Bool(C->getValue() && D->getValue());
                    case OR:
                        return new Bool(C->getValue() || D->getValue());
                    case NOT_EQUALS:
                        return new Bool(C->getValue() != D->getValue());
                    default:
                        UI_debug_pile("Pile Error: Bad operator passed to comparison().\n");
                        return NULL;
                }
            }
            else if(b == INT)
            {
                Int* D = static_cast<Int*>(B);
                switch(oper)
                {
                    case EQUALS:
                        return new Bool(C->getValue() == D->getValue());
                    case NOT_GREATER:
                    case LESS_EQUAL:
                        return new Bool(C->getValue() <= D->getValue());
                    case NOT_LESS:
                    case GREATER_EQUAL:
                        return new Bool(C->getValue() >= D->getValue());
                    case LESS:
                        return new Bool(C->getValue() < D->getValue());
                    case GREATER:
                        return new Bool(C->getValue() > D->getValue());
                    case AND:
                        return new Bool(C->getValue() && D->getValue());
                    case OR:
                        return new Bool(C->getValue() || D->getValue());
                    case NOT_EQUALS:
                        return new Bool(C->getValue() != D->getValue());
//.........这里部分代码省略.........
开发者ID:TheProjecter,项目名称:pile-build,代码行数:101,代码来源:eve_operators.cpp

示例15: writeBool

	inline void writeBool(std::ostream& ostrm,
		Bool arg)
	{
		BinarySerialization::write(ostrm, BINSIG_BOOL);
		arg.writeObject(ostrm);
	}
开发者ID:kkaempf,项目名称:openwbem,代码行数:6,代码来源:OW_BinarySerialization.hpp


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