コード例 #1
0
void CK2Character::readOpinionModifiers(Object* obj)
{
	vector<Object*> leaves = obj->getLeaves();
	for (vector<Object*>::iterator itr = leaves.begin(); itr != leaves.end(); ++itr)
	{
		int charId = atoi((*itr)->getKey().c_str());
		if (charId == 0)
			continue;  // shouldn't happen
		vector<Object*> modifiers = (*itr)->getLeaves();
		for (vector<Object*>::iterator mitr = modifiers.begin(); mitr != modifiers.end(); ++mitr)
		{
			CK2Opinion opinion(*mitr);
			opinionMods[charId].push_back(opinion);
		}
	}
}
コード例 #2
0
ファイル: dict.c プロジェクト: mayuedong/dictionary
/*************************************************************
* Function		:	AddNode
* Author 		:       bulldozer.ma
* Date 			:       2015-11-01
* Input 		:       dict *pHeader, char *str, unsigned int len
* Output 		:       N/A
* Return 		:       int
* Other 		:       N/A
* Description 		:       add entry
**************************************************************/
static int AddNode(dict *pHeader, char *str, unsigned int len)
{
	int iKey = -1;
      dictEntry *entry;
      dictht *ht;
    
       ht = opinion(pHeader);
       entry = (dictEntry *)malloc(sizeof(*entry));
	if (NULL == entry)
	{
		return DICT_ERROR;
	}
	iKey = getKey(str, len, ht);
    entry->next = ht->table[iKey];
	ht->table[iKey] = entry;
	entry->key = iKey;
	entry->value = str;
	ht->used++;
	return DICT_OK;
}