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


C++ DynArray类代码示例

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


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

示例1: if

/**
 * Constructor handles program flow. Gets user menu choice then acts on that.
 */
Controller::Controller() {

	bool running = true;
	int menuChoice = -1;

	do {
		menuChoice = view.getMenuChoice();

		if (menuChoice == 1) { // add movies

			DynArray movieList;
			view.getMovies(&movieList);

			localMovies.addAllMovies(&movieList);
			masterMovies.addMovies(&movieList);

		} else if (menuChoice == 2) { // delete movie

			string movieTitle = view.deleteMovie();

			Movie* removedMovie = localMovies.removeMovie(movieTitle);

			for (int i = 0; i < localMovies.getSize(); ++i) {
				if (localMovies.movieList[i]->getTitle().compare(movieTitle)
						== 0) {
					DynArray movieToRemove;
					movieToRemove.addMovie(localMovies.movieList[i]);
					masterMovies.removeMovies(&movieToRemove);
					break;
				}
			}

			delete removedMovie;

		} else if (menuChoice == 3) { // list all movies

			view.listMovies(&localMovies);

		} else if (menuChoice == 4) { // list movies by genre

			Genre genre = view.getGenre();
			DynArray genreMovies;

			for (int i = 0; i < localMovies.getSize(); ++i) {
				if (localMovies.movieList[i]->getGenre() == genre) {
					genreMovies.addMovie(localMovies.movieList[i]);
				}
			}

			view.listMovies(&genreMovies);

		} else if (menuChoice == 0) { // exit
			running = false;

		} else {
			view.displayMessage("Invalid menu option!");
		}
	} while (running);

}
开发者ID:chrismcmorran,项目名称:comp2404,代码行数:63,代码来源:Controller.cpp

示例2: SetExpiry

int Client::SetExpiry(const ByteString &key, uint64_t expiryTime)
{
	int			status;
	Command*	cmd;
	ByteString	args[2];
	DynArray<32> numString;

	VALIDATE_CLIENT();
	VALIDATE_KEY_LEN(key);
	VALIDATE_SAFE();
	VALIDATE_WRITE();

	numString.Writef("%U", expiryTime);

	args[0] = key;
	args[1] = numString;
	
	cmd = CreateCommand(KEYSPACECLIENT_SET_EXPIRY, SIZE(args), args);
	safeCommands.Append(cmd);
	
	if (IS_BATCHED())
	{
		result->AppendCommand(cmd);
		return KEYSPACE_SUCCESS;
	}
	
	result->Close();
	result->AppendCommand(cmd);

	EventLoop();
	status = result->CommandStatus();
	
	return status;
}
开发者ID:Kaperstone,项目名称:keyspace,代码行数:34,代码来源:KeyspaceClient.cpp

示例3: FindPaletteIndex

// FindPaletteIndex()
//  Returns the palette index that most closely matches the given
//  RGB value.  This only works in Indexed mode.  The optional low
//  and high values specify the low and hight palette indices to
//  to search (inclusive).  This is similar to the other
//  FindPaletteIndex() functions, but also takes a pointer to a
//  DynArray of palette indices to match against.
IMG_BYTE ImageClass::FindPaletteIndex( IMG_BYTE r, IMG_BYTE g, IMG_BYTE b, DynArray<int> &array ) {
  if( type != IMAGE_INDEXED )
    return 0;

  if( array.NumElements() == 0 )
    return 0;

  IMG_BYTE  closest    =    0;   // Closest index to the target color
  int       how_close  = 1000;   // 0 == perfect match
  int       this_try;

  int step  = sizeof( IMG_BYTE ) * 3;
  IMG_BYTE * rgb = &(palette[ (array[0]) ]);

  for( unsigned int i=0; i < array.NumElements(); i++ ) {
    rgb = GetPaletteColor( array[i] );

    if( r > rgb[0] )  this_try = r - rgb[0];   // Find the red difference
    else              this_try = rgb[0] - r;

    if( g > rgb[1] )  this_try += g - rgb[1];  // Find the green difference
    else              this_try += rgb[1] - g;

    if( b > rgb[2] )  this_try += b - rgb[2];  // Find the blue difference
    else              this_try += rgb[2] - b;

    if( this_try < how_close ) {               // See if this is closer than the last match
      closest   = array[i];
      how_close = this_try;
    }
  }

  return closest;
}
开发者ID:jangellx,项目名称:TMProLWPlugIns,代码行数:41,代码来源:ImageClass.cpp

示例4: main

int main(int argc, char **argv)
{
	init_shogun(&print_message, &print_message, &print_message);

	/* create example tree */
	CModelSelectionParameters* tree=create_param_tree();
	tree->print();
	SG_SPRINT("----------------------------------\n");

	/* build combinations of parameter trees */
	DynArray<CParameterCombination*> combinations;
	tree->get_combinations(combinations);

	apply_parameter_tree(combinations);

	/* print and directly delete them all */
	for (index_t i=0; i<combinations.get_num_elements(); ++i)
		combinations[i]->destroy(true, true);

	/* delete example tree (after processing of combinations because CSGObject
	 * (namely the kernel) of the tree is SG_UNREF'ed (and not REF'ed anywhere
	 * else) */
	tree->destroy();

	exit_shogun();

	return 0;
}
开发者ID:alesis,项目名称:shogun,代码行数:28,代码来源:modelselection_apply_parameter_tree.cpp

示例5: SetProperty

void CEntityPropertyHandler::SetProperty(IEntity *pIEntity, int index, const char *value)
{
	EntityId id = pIEntity->GetId();

	CMonoEntityExtension *pEntity = nullptr;
	if (IGameObject *pGameObject = static_cast<CScriptSystem *>(GetMonoScriptSystem())->GetIGameFramework()->GetGameObject(id))
		pEntity = static_cast<CMonoEntityExtension *>(pGameObject->QueryExtension(pIEntity->GetClass()->GetName()));

	// Only true after game has started, limiting this to changes made in Editor.
	if(pEntity && pEntity->IsInitialized())
		pEntity->SetPropertyValue(m_pProperties[index].info, value);
	else
	{
		bool exists = false;
		for(auto it = m_queuedProperties.begin(); it != m_queuedProperties.end(); ++it)
		{
			if((*it).first == id)
			{
				(*it).second.push_back(SQueuedProperty(m_pProperties[index].info, value));

				exists = true;
				break;
			}
		}
		if(!exists)
		{
			DynArray<SQueuedProperty> queuedPropertiesForEntity;
			queuedPropertiesForEntity.push_back(SQueuedProperty(m_pProperties[index].info, value));

			m_queuedProperties.insert(TQueuedPropertyMap::value_type(id, queuedPropertiesForEntity));
		}
	}
}
开发者ID:Orav,项目名称:CryMono,代码行数:33,代码来源:MonoEntityPropertyHandler.cpp

示例6: UpdateRenderMesh

void CClipVolumeProxy::UpdateRenderMesh(IRenderMesh* pRenderMesh, const DynArray<Vec3>& meshFaces)
{
	m_pRenderMesh = pRenderMesh;
	gEnv->pEntitySystem->ReleaseBSPTree3D(m_pBspTree);

	const size_t nFaceCount = meshFaces.size() / 3;
	if(nFaceCount > 0)
	{
		IBSPTree3D::FaceList faceList;
		faceList.reserve(nFaceCount);

		for(int i=0; i<meshFaces.size(); i+=3)
		{
			IBSPTree3D::CFace face;
			face.push_back(meshFaces[i + 0]);
			face.push_back(meshFaces[i + 1]);
			face.push_back(meshFaces[i + 2]);

			faceList.push_back(face);
		}

		m_pBspTree = gEnv->pEntitySystem->CreateBSPTree3D(faceList);
	}


	if(m_pEntity && m_pClipVolume)
		gEnv->p3DEngine->UpdateClipVolume(m_pClipVolume, m_pRenderMesh, m_pBspTree, m_pEntity->GetWorldTM(), !m_pEntity->IsHidden(), m_pEntity->GetName());
}
开发者ID:aronarts,项目名称:FireNET,代码行数:28,代码来源:ClipVolumeProxy.cpp

示例7: Breathe

void KChatSocket::Breathe(int msec)
{
	JgVirtualSocket::Breathe(msec);

	void* packetPtrs[64];
	char packetBuffer[10240];
	DynArray<void*> packets;
	packets.attach(&packetPtrs[0], 64, 0);

	KClientGateListener* cgl = KClientGateListener::getSingletonPtr();

	while(!m_shouldRemove)
	{
		int_r packetNum = this->ReadPackets(packetBuffer, sizeof(packetBuffer), packets, 64);
		if(packetNum < 1) break;
		for(int_r i=0; i<packetNum; i++)
		{
			JgPacketHead* head = (JgPacketHead*)packets[(int)i];
			//cgl->m_gateChatC.Process(this, head);
			if(m_shouldRemove) break;
		}
	}

	if(m_shouldRemove)
	{
		cgl->m_vsocketManager.detach(this);
		m_pGatewaySocket->setChatCnn(NULL);
		Log(LOG_DEBUG, "debug: free %s", this->ToString().c_str());
		this->Destroy();
	}
}
开发者ID:joyfish,项目名称:zgc,代码行数:31,代码来源:KSocketDefine.cpp

示例8: StructuredDatabaseTest

int StructuredDatabaseTest()
{
	Table* table;
	int user_id;
	DynArray<1024> what;
	DynArray<1024> where;

	table = new Table(&database, "structured_test");
	table->Truncate();
	user_id = InsertUser(table, "dopey", "dopeypass", "online");
	InsertEvent(table, user_id, "dinner", "cheezburger", "2009-03-24 01:09:00");
	InsertEvent(table, user_id, "meeting", "important", "2009-03-24 11:12:00");

	// SELECT * FROM event WHERE user=%d AND date > 2009-03-24 01
	what.Printf("event:user:%d", user_id);
	where.Printf("date:2009-03-24 01");
	//TableSelector selector(what.buffer, where.buffer);
//	QuerySelector selector("SELECT date, note FROM event WHERE user_id=%d", user_id);
//	table->Visit(selector);

	ListTableVisitor visitor;
	table->Visit(visitor);
	
	return TEST_SUCCESS;
}
开发者ID:Kaperstone,项目名称:keyspace,代码行数:25,代码来源:TableVisitorTest.cpp

示例9: Set

bool Endpoint::Set(const char* ip_port, bool resolv)
{
	const char*		p;
	int				port;
	bool			ret;
	DynArray<32>	ipbuf;

	p = ip_port;
	
	while (*p != '\0' && *p != ':')
		p++;
	
	if (*p == '\0')
	{
		Log_Trace("No ':' in host specification");
		return false;
	}

	ipbuf.Append(ip_port, p - ip_port);
	ipbuf.Append("", 1);
	p++;
	
	port = -1;
	port = atoi(p);
	if (port < 1 || port > 65535)
	{
		Log_Trace("atoi() failed to produce a sensible value");
		return false;
	}

	ret = Set(ipbuf.buffer, port, resolv);
	
	return ret;
}
开发者ID:Kaperstone,项目名称:keyspace,代码行数:34,代码来源:Endpoint.cpp

示例10: HELIUM_VERIFY

void SimpleSortedSetData< KeyT, CompareKeyT, AllocatorT >::Serialize( ArchiveT& archive )
{
    DynArray< ObjectPtr > components;
    components.Reserve( m_Data->GetSize() );

    {
        DataType::ConstIterator itr = m_Data->Begin();
        DataType::ConstIterator end = m_Data->End();
        for ( ; itr != end; ++itr )
        {
            ObjectPtr dataElem = Registry::GetInstance()->CreateInstance( Reflect::GetDataClass< KeyT >() );

            // downcast to data type
            Data* dataSer = AssertCast< Data >( dataElem );

            // connect to our map data memory address
            dataSer->ConnectData( const_cast< KeyT* >( &( *itr ) ) );

            // serialize to the archive stream
            HELIUM_VERIFY( components.New( dataSer ) );
        }
    }

    archive.SerializeArray( components );

    DynArray< ObjectPtr >::Iterator itr = components.Begin();
    DynArray< ObjectPtr >::Iterator end = components.End();
    for ( ; itr != end; ++itr )
    {
        Data* ser = AssertCast< Data >( *itr );
        ser->Disconnect();

        // might be useful to cache the data object here
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:35,代码来源:SortedSetData.cpp

示例11: TXT

void SimpleObjectSortedMapData< KeyT, CompareKeyT, AllocatorT >::Deserialize( ArchiveT& archive )
{
    DynArray< ObjectPtr > components;
    archive.DeserializeArray( components, ArchiveFlags::Sparse );

    size_t componentCount = components.GetSize();
    if ( componentCount % 2 != 0 )
    {
        throw Reflect::DataFormatException( TXT( "Unmatched map objects" ) );
    }

    // if we are referring to a real field, clear its contents
    m_Data->Clear();
    m_Data->Reserve( componentCount / 2 );

    DynArray< ObjectPtr >::Iterator itr = components.Begin();
    DynArray< ObjectPtr >::Iterator end = components.End();
    while ( itr != end )
    {
        Data* key = SafeCast< Data >( *itr );
        ++itr;
        Object* value = *itr;
        ++itr;

        if ( key )  // The object value can be null, so don't check it here.
        {
            KeyT k;
            Data::GetValue( key, k );
            (*m_Data)[ k ] = value;
        }
    }
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例12: boot_run

void Boot::boot_run() const
 {
  DynArray<unsigned> boot;
  
  buildBoot(boot,Range(&__std_boot_beg,&__std_boot_end));

  __std_boot(boot.getPtr(),boot.getPtr()+boot.getLen());
 }
开发者ID:SergeyStrukov,项目名称:CCore,代码行数:8,代码来源:Boot.cpp

示例13: HELIUM_ASSERT

/// Resolve a set of shader preprocessor options from the associated index.
///
/// @param[in]  shaderType    Type of shader.
/// @param[in]  index         Option set index.
/// @param[out] rToggleNames  List of enabled shader toggles.
/// @param[out] rSelectPairs  List shader selection pair values.
void Shader::Options::GetOptionSetFromIndex(
    RShader::EType shaderType,
    size_t index,
    DynArray< Name >& rToggleNames,
    DynArray< SelectPair >& rSelectPairs ) const
{
    HELIUM_ASSERT( static_cast< size_t >( shaderType ) < static_cast< size_t >( RShader::TYPE_MAX ) );

    rToggleNames.Resize( 0 );
    rSelectPairs.Resize( 0 );

    uint32_t shaderTypeMask = ( 1 << shaderType );

    size_t shaderToggleCount = m_toggles.GetSize();
    for( size_t shaderToggleIndex = 0; shaderToggleIndex < shaderToggleCount; ++shaderToggleIndex )
    {
        const Toggle& rShaderToggle = m_toggles[ shaderToggleIndex ];
        if( !( rShaderToggle.shaderTypeFlags & shaderTypeMask ) )
        {
            continue;
        }

        if( index & 0x1 )
        {
            HELIUM_VERIFY( rToggleNames.New( rShaderToggle.name ) );
        }

        index >>= 1;
    }

    size_t shaderSelectCount = m_selects.GetSize();
    for( size_t shaderSelectIndex = 0; shaderSelectIndex < shaderSelectCount; ++shaderSelectIndex )
    {
        const Select& rShaderSelect = m_selects[ shaderSelectIndex ];
        if( !( rShaderSelect.shaderTypeFlags & shaderTypeMask ) )
        {
            continue;
        }

        const DynArray< Name >& rShaderSelectChoices = rShaderSelect.choices;
        size_t shaderSelectChoiceCount = rShaderSelectChoices.GetSize();

        size_t selectIndexMultiplier = shaderSelectChoiceCount + rShaderSelect.bOptional;

        size_t selectIndex = index % selectIndexMultiplier;
        index /= selectIndexMultiplier;

        if( !rShaderSelect.bOptional || selectIndex != shaderSelectChoiceCount )
        {
            SelectPair* pSelectPair = rSelectPairs.New();
            HELIUM_ASSERT( pSelectPair );
            pSelectPair->name = rShaderSelect.name;
            pSelectPair->choice = rShaderSelectChoices[ selectIndex ];
        }
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:62,代码来源:Shader.cpp

示例14: ReadCacheObjectFromBuffer

Reflect::ObjectPtr Helium::Cache::ReadCacheObjectFromBuffer( const DynArray< uint8_t > &_buffer )
{
    if (_buffer.GetSize() == 0)
    {
        Reflect::ObjectPtr null_object;
        return null_object;
    }

    return ReadCacheObjectFromBuffer(_buffer.GetData(), 0, _buffer.GetSize());
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例15: count

	int count(const char* key){
		DynArray<int> * a = valarray->get(keys->indexofVal(key));
		int count = 0;
		for(int i = 0; i<a->getLength();i++){
			if(a->get(i) >= 0){
				count++;
			}	
		}
		return count;
	}
开发者ID:schmittlema,项目名称:Multimap,代码行数:10,代码来源:multimap.cpp


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