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


C++ DynamicArray类代码示例

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


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

示例1: testview

bool
testview(Pooma::Tester &tester, DynamicArray<T,Dynamic> &da,
	 const CA &daview)
{
  tester.out() << "In testview:" << std::endl;
  tester.out() << "    da = " << da << std::endl;
  tester.out() << "daview = " << daview << std::endl;

  // the following should crash
  tester.out() << "Trying to create values within da ..." << std::endl;
  bool result = false;
#if POOMA_EXCEPTIONS
  try {
    da.create(3);
    tester.out() << "Ack! create call didn't throw!!!" << std::endl;
    result = false;
  }
  catch(const Pooma::Assertion &a)
  {
    tester.out() << "Caught assertion - it worked!" << std::endl;
    result = true;
  }
#else
  da.create(3);
  tester.out() << "Ack! Program should have aborted and never gotten here!"
               << std::endl;
#endif

  return result;
}
开发者ID:pathscale,项目名称:freepooma-testsuite,代码行数:30,代码来源:dynamic_array_badcreate.C

示例2: storeImage

void storeImage(const FilePath& filename, DynamicArray<unsigned char> data,
    unsigned int width, unsigned int height)
{
    constexpr int CHANNEL_COUNT = 3;

    OutFileStream file(filename.c_str(), OutFileStream::binary);

    if (!file.is_open())
        throw InvalidArgumentException("Cannot open output file: " + filename.toString());

    // Image is vertically flipped
    DynamicArray<unsigned char> data_flip(data.size());

    const unsigned int line_size = width * CHANNEL_COUNT;

    // Vertically flip lines
    for (unsigned int i = 0; i < height; ++i)
    {
        std::memcpy(
            data_flip.data() + i * line_size,
            data.data() + (height - i - 1) * line_size,
            line_size
        );
    }

    // Write function
    stbi_write_func* func = [] (void* context, void* data, int size) {
        reinterpret_cast<OutFileStream*>(context)->write(reinterpret_cast<const char*>(data), size);
    };

    // Copy data
    if (!stbi_write_png_to_func(func, &file, width, height, CHANNEL_COUNT, data_flip.data(), 0))
        throw RuntimeException("Unable to write a picture");
}
开发者ID:GeorgievLab,项目名称:CeCe-cli,代码行数:34,代码来源:Image.cpp

示例3: TEST

TEST( DynamicArray, equalOperator ){
	DynamicArray<string> arrayEqOp = testArrayOne;
	EXPECT_EQ( testArrayOne.getLength(), arrayEqOp.getLength() );
	for( int i = 0; i < testArrayOne.getLength(); ++i ){
		EXPECT_TRUE( testArrayOne[i] == arrayEqOp[i] );
	}
}
开发者ID:curtisai,项目名称:CS585MKII,代码行数:7,代码来源:test_dynamic_array.cpp

示例4: updateJointOrdering

/**
	HACK!
*/
void Character::updateJointOrdering(){
	if( jointOrder.size() == joints.size() ) 
		return; // HACK assume ordering is ok
	jointOrder.clear();

	if (!root)
		return;
	DynamicArray<ArticulatedRigidBody*> bodies;
	bodies.push_back(root);

	int currentBody = 0;

	while ((uint)currentBody<bodies.size()){
		//add all the children joints to the list
		for (int i=0;i<bodies[currentBody]->getChildJointCount();i++){
			Joint *j = bodies[currentBody]->getChildJoint(i);
			jointOrder.push_back( getJointIndex(j->getName()) );
			bodies.push_back(bodies[currentBody]->getChildJoint(i)->getChild());
		}
		currentBody++;
	}

	reverseJointOrder.resize( jointOrder.size() );
	for( uint i=0; i < jointOrder.size(); ++i )
		reverseJointOrder[jointOrder[i]] = i;

}
开发者ID:MontyThibault,项目名称:cartwheel-3d-Research-Modifications,代码行数:30,代码来源:Character.cpp

示例5: testMutate

    void testMutate ()
    {
        String s;
        DynamicArray <T> v;

        s = "push_back (" + String::fromNumber <int> (numberToMutate) + ")";
        beginTestCase (s);
        for (std::size_t i = 0; i < numberToMutate; ++i)
            v.push_back (T (String::fromNumber (i)));
        pass ();

        s = "read [] (" + String::fromNumber <int> (numberToMutate) + ")";
        beginTestCase (s);
        for (std::size_t i = 0; i < numberToMutate; ++i)
            expect (v [i].msg == String::fromNumber (i));

        s = "write [] (" + String::fromNumber <int> (numberToMutate) + ")";
        beginTestCase (s);
        for (std::size_t i = 0; i < numberToMutate; ++i)
            v [i].msg = "+" + String::fromNumber (i);
        pass ();

        s = "verify [] (" + String::fromNumber <int> (numberToMutate) + ")";
        beginTestCase (s);
        for (std::size_t i = 0; i < numberToMutate; ++i)
            expect (v [i].msg == String ("+") + String::fromNumber (i));
    }
开发者ID:Aiolossong,项目名称:rippled,代码行数:27,代码来源:DynamicArray.cpp

示例6: TEST

TEST( Map, Iterator )
{
    using namespace nge::cntr;
    using namespace nge::mem;
    using namespace nge;

    DefaultAllocator<String> alloc;
    CountingAllocator<Map<String, String>::Pair> pairAlloc;
    CountingAllocator<uint32> binAlloc;

    Map<String, String> map( &pairAlloc, &binAlloc );
    DynamicArray<String> keys = getKeys( &alloc );

    uint32 i;
    for ( i = 0; i < keys.size(); ++i )
    {
        map[keys[i]] = keys[i];
    }

    for ( auto iter = map.cbegin(); iter != map.cend(); ++iter )
    {
        ASSERT_STREQ( iter->key.c_str(), iter->value.c_str() );
    }

    auto iter = map.cbegin();
    for ( i = 0; i < map.size(); ++i, ++iter )
    {
        ASSERT_STREQ( keys[i].c_str(), iter->key.c_str() );
        ASSERT_STREQ( keys[i].c_str(), iter->value.c_str() );
    }
}
开发者ID:numinousgames,项目名称:engine,代码行数:31,代码来源:map.t.cpp

示例7: getComponentNames

int getComponentNames (ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char **argv){

	// getComponentNames stateIdx trajectoryIdx
	if( argc != 3 ) return TCL_ERROR;

	ControllerEditor* obj = (ControllerEditor*)clientData;

	int idx = atoi( argv[1] );
	SimBiConState* state = obj->getFramework()->getController()->getState( idx );
	if( !state ) return  TCL_ERROR;
	idx = atoi( argv[2] );
	Trajectory* trajectory = state->getTrajectory( idx );
	if( !trajectory ) return  TCL_ERROR;

	DynamicArray<const char*> componentNames;
	for( uint i = 0; i < trajectory->components.size(); ++i ) {
		char* componentName = new char[ 32 ];
		sprintf( componentName, "Component %d", i );
		componentNames.push_back( componentName );
	}	

	char* result = stringListToTclList( componentNames );

	for( uint i = 0; i < componentNames.size(); ++i )
		delete[] componentNames[i];

	Tcl_SetResult(interp, result, TCL_DYNAMIC);
	return TCL_OK;

}
开发者ID:aashithk,项目名称:BipedSoccer,代码行数:30,代码来源:ControllerEditor.cpp

示例8: setToSize

DynamicArray<T,chrunkSize>::DynamicArray(DynamicArray<T,chrunkSize> &other):items(0)
{
    setToSize(other.length());

    for(size_t i = 0; i < other.length(); i++)
        set(i, other.get(i));
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:7,代码来源:DynamicArray.cpp

示例9:

void CartWheel3D::runStep(double dt) {
    
    _nTime += dt;
    DynamicArray<ContactPoint>* contactPoints = _world->getContactForces();
    DynamicArray<Vector3d> humanPositions;
    
    for (HumanItr itr = _humans.begin(); itr != _humans.end(); itr++) {
        Human* human = (*itr).second;
        SimBiController* c = human->getController();
        if (NULL != c) {
            c->performPreTasks(dt, contactPoints);

            // Save the current position
            humanPositions.push_back(human->getPosition());

            BehaviourController* b = human->getBehaviour();
            if (NULL != b) {
                if (b->shouldAbort()) {

                }
            }
        }
    }
    _world->advanceInTime(dt);

    bool isHumansWorking = false;
    bool isObjsWorking = false;
    contactPoints = _world->getContactForces();
    for (HumanItr itr = _humans.begin(); itr != _humans.end(); itr++) {
        Human* human = (*itr).second;
        SimBiController* c = human->getController();

        if (NULL != c) {
            c->performPostTasks(dt, contactPoints);

            // Save the current position
            humanPositions.push_back(human->getPosition());

            BehaviourController* b = human->getBehaviour();
            if (NULL != b) {
                if (b->shouldAbort()) {

                }
            }
        }        
        if(_behaviorsManager->runStep(human->getName().c_str(), _nTime)) {
//            printf("nTime: %f\n", _nTime);
            isHumansWorking = true;
        }
    }
    for(int i=0; i<_objects.size(); i++) {
        if(_behaviorsManager->runStep(_objects[i].c_str(), _nTime)) {
            isObjsWorking = true;
        }
    }
    if(!isHumansWorking && !isObjsWorking) {
        _behaviorsManager->setBehaviorsDone(true);
    } 
}
开发者ID:ninod2014,项目名称:ua-cartwheel,代码行数:59,代码来源:CartWheel3D.cpp

示例10: png_GetWidth

int png_GetWidth(void *ptrCache){
	PngImgData *pidPtr;
	DynamicArray *daPtr;
	daPtr=(DynamicArray*)ptrCache;
	pidPtr=(PngImgData*)daPtr->GetItem(0);
//	printf("Getting width!\n");
	return pidPtr->width;
}
开发者ID:patrickhno,项目名称:interface,代码行数:8,代码来源:PngLoader.cpp

示例11: png_GetHeight

int png_GetHeight(void *ptrCache){
	PngImgData *pidPtr;
	DynamicArray *daPtr;
	daPtr=(DynamicArray*)ptrCache;
	pidPtr=(PngImgData*)daPtr->GetItem(0);
//	printf("Getting height!\n");
	return pidPtr->height;
}
开发者ID:patrickhno,项目名称:interface,代码行数:8,代码来源:PngLoader.cpp

示例12: getNames

    /**
     * @brief Returns list of configuration names.
     *
     * @return
     */
    DynamicArray<String> getNames() const noexcept override
    {
        DynamicArray<String> names;

        for (auto attr : m_node.attributes())
            names.push_back(attr.name());

        return names;
    }
开发者ID:GustavoPB,项目名称:CeCe,代码行数:14,代码来源:Configuration.hpp

示例13: clear

DynamicArray<T,chrunkSize> DLL_EXPORT DynamicArray<T,chrunkSize>::operator =(DynamicArray<T,chrunkSize> &other)
{
    clear();

    setToSize(other.length());

    for(size_t i = 0; i < other.length(); i++)
        set(i, other.get(i));
}
开发者ID:enjoythelive1,项目名称:memory-manage,代码行数:9,代码来源:DynamicArray.cpp

示例14: fullClear

    void RelationalState::reset(PosState & last, CartWheel3D * cw) {
        double atThresh = 1.0;
        double changeThresh = 0.0001;
        //get each human (just doing humans now
        fullClear();
        if (last.getNumVectors() == 0)
            return;
        int numThings = last.getNumVectors();
        //just binary relations for right now
        for (int i = 0; i < numThings; i++) {
            Vector3d pos1 = findPlace(i, last, cw);
            string n1 = findName(i, last);
            for (int j = 0; j < numThings; j++) {
                if (i == j)
                    continue;
                Vector3d pos2 = findPlace(j, last, cw);
                double dist = ControlUtils::eucDistance2d(pos1, pos2);
                string n2 = findName(j, last);
                double prevDist = ControlUtils::eucDistance2d(
                        *(last.getPosition(n1)), *(last.getPosition(n2)));

                //                      cout<<"rel check "<<dist<<"  "<<prevDist<<endl;
                if (dist < atThresh) {
                    addRelation(*(new Relation("At", n1, n2)));
                }

                if (fabs(dist - prevDist) > changeThresh) {
                    if (dist - prevDist < 0)
                        addRelation(*(new Relation("DistanceDecreasing", n1, n2)));
                    else
                        addRelation(*(new Relation("DistanceIncreasing", n1, n2)));
                } else {
                    addRelation(*(new Relation("DistanceConstant", n1, n2)));
                }

            }
        }

        //      typedef boost::shared_ptr<Relation> RelationPtr;

        DynamicArray<ContactPoint>* contactPoints = cw->getWorld()->getContactForces();

        for (std::vector<ContactPoint>::iterator iter = contactPoints->begin(); iter != contactPoints->end(); ++iter) {
            //              addRelation(  *( new Relation("Contact",
            //                                                                        iter->rb1->getName(),
            //                                                                        iter->rb2->getName()) )  );
            Relation contact("Contact",
                    StringUtils::split(iter->rb1->getName(), ' ')[0],
                    StringUtils::split(iter->rb2->getName(), ' ')[0]);
            if (!contains(contact))
                addRelation(*(new Relation("Contact",
                    StringUtils::split(iter->rb1->getName(), ' ')[0],
                    StringUtils::split(iter->rb2->getName(), ' ')[0])));

        }
    }
开发者ID:ninod2014,项目名称:ua-cartwheel,代码行数:56,代码来源:RelationalState.cpp

示例15: measure_time

void Module::update(simulator::Simulation& simulation, units::Time dt)
{
    // Store time step
    m_step = dt;

    auto _ = measure_time("agglutination", simulator::TimeMeasurementIterationOutput(simulation));

    // Get physics world
    auto& world = simulation.getWorld();

    // Foreach pending bodies
    for (const auto& p : m_toJoin)
    {
        b2WeldJointDef joint;
        joint.Initialize(p.bodyA, p.bodyB, p.bodyA->GetWorldCenter());
        JointUserData* jUserData = new JointUserData();
        jUserData->module = this;
        jUserData->Kd = p.dConst;
        joint.userData = jUserData;
        world.CreateJoint(&joint);
    }

    m_toJoin.clear();

    // Joints to remove
    DynamicArray<b2Joint*> toRemove;

    // Foreach active joints
    for (auto joint = world.GetJointList(); joint != nullptr; joint = joint->GetNext())
    {
        const JointUserData* jUserData = reinterpret_cast<const JointUserData*>(joint->GetUserData());
        // Not our joint
        if (jUserData == nullptr)
            continue;
        if (jUserData->guard != '@')
            continue;

        std::bernoulli_distribution dist(
            getDisassociationPropensity(
                m_step,
                jUserData->Kd
            )
        );

        if (dist(g_gen))
        {
            Log::debug("Released: ", joint->GetBodyA(), ", ", joint->GetBodyB());
            toRemove.push_back(joint);
            delete jUserData;
        }
    }

    // Destroy joints
    for (auto joint : toRemove)
        world.DestroyJoint(joint);
}
开发者ID:GustavoPB,项目名称:CeCe,代码行数:56,代码来源:Module.cpp


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