本文整理汇总了C++中map类的典型用法代码示例。如果您正苦于以下问题:C++ map类的具体用法?C++ map怎么用?C++ map使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dfs
void dfs(int id,int depth,const map<int,string>&id2name,const map<int,deque<int> >&children){
cout<<string(depth,'.')<<id2name.at(id)<<endl;
if(children.find(id)!=children.end())for(auto &e:children.at(id)){
dfs(e,depth+1,id2name,children);
}
}
示例2: initAssetManager
namespace hg
{
AssetManager assetManager;
map<string, MusicData> musicDataMap;
map<string, StyleData> styleDataMap;
map<string, LevelData> levelDataMap;
map<string, ProfileData> profileDataMap;
map<string, EventData> eventDataMap;
map<string, PackData> packDataMap;
ProfileData* currentProfilePtr{nullptr};
map<string, vector<string>> levelIdsByPackMap;
vector<string> packPaths;
void initAssetManager() { assetManager.loadFolder("Assets/"); }
AssetManager& getAssetManager() { return assetManager; }
void loadAssets()
{
log("loading profiles", "LoadAssets"); loadProfiles();
for(string packPath : getScan<Mode::Single, Type::Folder>("Packs/"))
{
string packName{packPath.substr(6, packPath.length() - 6)};
string packLua{""};
for(const auto& path : getScan<Mode::Recurse, Type::File, Pick::ByExt>(packPath, ".lua")) packLua.append(getFileContents(path));
string packHash{Online::getMD5Hash(packLua + HG_SKEY1 + HG_SKEY2 + HG_SKEY3)};
Json::Value packRoot{getRootFromFile(packPath + "/pack.json")};
PackData packData(packName, packRoot["name"].asString(), packRoot["priority"].asFloat(), packHash);
packDataMap.insert(make_pair(packName, packData));
}
vector<PackData> packDatasToQuery;
for(pair<string, PackData> packDataPair : packDataMap) packDatasToQuery.push_back(packDataPair.second);
sort(begin(packDatasToQuery), end(packDatasToQuery), [](PackData a, PackData b) { return a.getPriority() < b.getPriority(); });
for(PackData packData : packDatasToQuery)
{
string packName{packData.getId()}, packPath{"Packs/" + packName + "/"};
packPaths.push_back("Packs/" + packName + "/");
log("loading " + packName + " music", "LoadAssets"); loadMusic(packPath);
log("loading " + packName + " music data", "LoadAssets"); loadMusicData(packPath);
log("loading " + packName + " style data", "LoadAssets"); loadStyleData(packPath);
log("loading " + packName + " level data", "LoadAssets"); loadLevelData(packPath);
log("loading " + packName + " events", "LoadAssets"); loadEvents(packPath);
log("loading " + packName + " custom sounds", "LoadAssets"); loadCustomSounds(packName, packPath);
}
}
void loadCustomSounds(const string& mPackName, const string& mPath)
{
for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Sounds/", ".ogg"))
{
string fileName{getNameFromPath(filePath, mPath + "Sounds/", "")};
assetManager.loadSound(mPackName + "_" + fileName, filePath);
assetManager.getSound(mPackName + "_" + fileName).setVolume(getSoundVolume());
}
}
void loadMusic(const string& mPath)
{
for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Music/", ".ogg"))
{
string fileName{getNameFromPath(filePath, mPath + "Music/", ".ogg")};
auto& music(assetManager.loadMusic(fileName, filePath));
music.openFromFile(filePath);
music.setVolume(getMusicVolume());
music.setLoop(true);
}
}
void loadMusicData(const string& mPath)
{
for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Music/", ".json"))
{
MusicData musicData{loadMusicFromJson(getRootFromFile(filePath))};
musicDataMap.insert(make_pair(musicData.getId(), musicData));
}
}
void loadStyleData(const string& mPath)
{
for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Styles/", ".json"))
{
StyleData styleData{loadStyleFromJson(getRootFromFile(filePath))};
styleData.setRootPath(filePath);
styleDataMap.insert(make_pair(styleData.getId(), styleData));
}
}
void loadLevelData(const string& mPath)
{
for(auto filePath : getScan<Mode::Single, Type::File, Pick::ByExt>(mPath + "Levels/", ".json"))
{
Json::Value root{getRootFromFile(filePath)};
string luaScriptPath{mPath + "Scripts/" + root["lua_file"].asString()};
LevelData levelData{loadLevelFromJson(root)};
levelData.setPackPath(mPath);
levelData.setLevelRootPath(filePath);
levelData.setStyleRootPath(getStyleData(levelData.getStyleId()).getRootPath());
levelData.setLuaScriptPath(luaScriptPath);
//.........这里部分代码省略.........
示例3: react
void react(EjectResMsg ePacket) {
map<int, InjectReqMsg>::iterator it = inTransitPackets.find(ePacket.id);
if(it == inTransitPackets.end()) {
cerr << "Error: couldn't find in transit packet " << ePacket.id << endl;
exit(-1);
}
InjectReqMsg request = it->second;
InjectReqMsg response;
inTransitPackets.erase(it);
map<int, transaction_t>::iterator trans = inTransitTransactions.find(request.address);
trans->second.total_time += ePacket.elapsed;
if(request.msgType == REQUEST &&
(request.coType == WRITE || request.coType == READ)) {
//Handle Read/Write Requests
if((int) request.address == request.id) {
//This is an initiating request. Should we forward it or go to
//memory?
bool isForwarded = g_toForward[g_hierClass][request.dest][request.coType].Generate() == 0;
if(isForwarded) {
int destination = g_forwardDest[g_hierClass][state][request.dest].Generate();
destination = destination*2;
if(destination % 2 != 0) {
cerr << "Error: Invalid destination for forwarded request." << endl;
exit();
}
QueuePacket(request.dest, destination, REQUEST, request.coType,
CONTROL_SIZE, cycle + 1, request.address);
if(request.coType == WRITE) {
//How many invalidates to send
int numInv = g_numInv[g_hierClass][state][request.dest].Generate();
int s = state;
if(numInv <= 0) {
return;
}
//Ensure invalidate destinations are unique (i.e. no two
//invalidate messages to the same destination)
set<int> destinations;
destinations.insert(destination); //Request already forwarded here
while(destinations.size() != (unsigned int) numInv) {
int dest = g_invDest[g_hierClass][s][request.dest].Generate();
dest = dest*2;
destinations.insert(dest);
}
for(set<int>::iterator it = destinations.begin();
it != destinations.end(); ++it) {
QueuePacket(request.dest, *it, REQUEST, INV,
CONTROL_SIZE, cycle + 1, request.address);
trans->second.invs_sent++;
}
}
} else {
//Access memory, queue up a data response for the future
QueuePacket(request.dest, request.source, RESPONSE, DATA,
DATA_SIZE, cycle + 80, request.address);
}
return;
} else {
//This is not an initiating request, so it's a forwarded request
//Respond with Data
QueuePacket(request.dest,
trans->second.source, RESPONSE,
DATA, DATA_SIZE, cycle + 1, request.address);
}
} else if(request.msgType == REQUEST &&
(request.coType == PUTC || request.coType == PUTD)) {
//Respond with WB_ACK
QueuePacket(request.dest, request.source, RESPONSE, WB_ACK,
CONTROL_SIZE, cycle + 1, request.address);
} else if(request.msgType == REQUEST && request.coType == INV) {
//Respond with Ack
QueuePacket(request.dest, trans->second.source,
RESPONSE, ACK, CONTROL_SIZE, cycle + 1, request.address);
} else if(request.msgType == RESPONSE && request.coType == DATA) {
trans->second.data_received = true;
//Send unblock
QueuePacket(inTransitTransactions[request.address].source,
inTransitTransactions[request.address].dest, RESPONSE, UNBLOCK,
CONTROL_SIZE, cycle + 1, request.address);
} else if(request.msgType == RESPONSE && request.coType == ACK) {
trans->second.acks_received++;
} else if(request.msgType == RESPONSE && request.coType == UNBLOCK) {
trans->second.unblock_received = true;
}
if(trans->second.Completed()) {
inTransitTransactions.erase(trans);
}
//.........这里部分代码省略.........
示例4: while
double PointSensor::getDistance(map<uint32_t, hesperia::data::environment::Polygon> &mapOfPolygons) {
Point3 nearest;
double distanceToSensor = -1;
map<uint32_t, hesperia::data::environment::Polygon>::const_iterator it = mapOfPolygons.begin();
while (it != mapOfPolygons.end()) {
Polygon p = it->second;
// Get overlapping parts of polygon...
Polygon contour = m_FOV.intersectIgnoreZ(p);
if (contour.getSize() > 0) {
// Get nearest point from contour.
const vector<Point3> listOfPoints = contour.getVertices();
vector<Point3>::const_iterator jt = listOfPoints.begin();
while (jt != listOfPoints.end()) {
Point3 pt = (*jt++);
double d = (pt - m_sensorPosition).lengthXY();
if (isInFOV(pt)) {
if ((distanceToSensor < 0) || (d < distanceToSensor)) {
nearest = pt;
distanceToSensor = d;
}
}
}
}
it++;
}
if (distanceToSensor > m_clampDistance) {
distanceToSensor = -1;
}
// Apply fault model.
// Firstly, calculate the noise data if required.
double fault = 0;
if (!(distanceToSensor < 0)) {
// Determine the random data from the range -1.0 .. 1.0 multiplied by the defined m_faultModelNoise.
fault = ((100-(1 + (rand()%200)))/100.0) * m_faultModelNoise;
distanceToSensor += fault;
// If the distanceToSensor is less than zero, set the returned value to -1.
if (distanceToSensor < 0) {
distanceToSensor = -1;
}
if ( (fault > 0) || (fault < 0) ) {
cerr << m_name << "(" << m_id << ")" << ": " << "faultModel.noise: " << "Adding " << fault << " to distance." << endl;
}
}
// Secondly, check wether the current distance to be returned need to be skipped (i.e. overwritten by -1).
// Thus, increment the current iteration.
m_faultModelSkipCounter++;
// Limit the counter range.
if (m_faultModelSkipCounter == 100) {
m_faultModelSkipCounter = 0;
}
if (m_faultModelSkip > 0) {
unsigned int modulo = (unsigned int)(1.0/m_faultModelSkip);
if ( (modulo == 0) || (m_faultModelSkipCounter % modulo) == 0 ) {
cerr << m_name << "(" << m_id << ")" << ": " << "faultModel.skip: " << "Skipping current frame (" << m_faultModelSkip << "/" << m_faultModelSkipCounter << ")." << endl;
distanceToSensor = -1;
}
}
return distanceToSensor;
}
示例5: sortMapByValue
vector<pair<int, double> > sortMapByValue(const map<int, double>& pccMap) {
vector<pair<int, double> > vec(pccMap.begin(), pccMap.end());
sort(vec.begin(), vec.end(), cmpPairbyValue);
return vec;
}
示例6: main
int main(int argc, char* argv[])
{
int retval = 0;
ForestT* forest = NULL;
NetVT* net_values_FF = NULL;
int* retvals = NULL;
IdType** thread_modules = NULL;
NetVT** net_values_E = NULL;
do
{
if ((retval = ReadInput(argc, argv))) break;
if ((retval = MakeOrder() )) break;
if ((retval = GetDependency() )) break;
#pragma omp parallel
{
int thread_num = omp_get_thread_num();
int num_threads = omp_get_num_threads();
#pragma omp single
{
do
{
retvals = new int[num_threads];
memset(retvals, 0, sizeof(int) * num_threads);
forest = new ForestT;
if ((retvals[thread_num] = forest->Init(num_threads, num_inputs, net_widths))) break;
thread_inputs = new ValueType*[num_threads];
thread_outputs = new ValueType*[num_threads];
thread_modules = new IdType*[num_threads];
for (SizeType i=0; i<num_threads; i++)
{
thread_inputs[i] = new ValueType[max_num_inputs];
thread_outputs[i] = new ValueType[max_num_outputs];
thread_modules[i] = new IdType[num_modules];
}
net_values_FF = new NetVT[num_nets];
//prepare the inputs
for (SizeType i=0; i<num_inputs; i++)
{
MapT* map = &net_values_FF[i].root_Ids;
for (ValueType j=0; j< (1<<net_widths[i]); j++)
{
IdType temp_Id = NULL_Id;
retvals[thread_num] = forest->NewTree(thread_num, i, j, temp_Id);
if (retvals[thread_num] != 0) break;
map->insert(MapTP(j, temp_Id));
}
}
for (IdType i=0; i<num_modules; i++)
thread_modules[thread_num][i] = i;
// Evaluate the FF cicuit
if ((retvals[thread_num] = Evaluate(num_modules, thread_modules[thread_num], net_values_FF, NULL, forest, thread_num))) break;
if ((retvals[thread_num] = GenerateErrors())) break;
net_values_E = new NetVT*[num_errors];
for (SizeType i=0; i<num_errors; i++)
net_values_E[i] = new NetVT[num_nets];
} while(0);
}
#pragma omp for
for (IdType i=0; i<num_errors; i++)
{
if (retvals[thread_num] != 0) continue;
IdType error_type = error_types.find(i)->second;
IdType error_Id = error_Ids .find(i)->second;
IdType error_ref = error_refs .find(i)->second;
IdType error_cond = error_conds.find(i)->second;
IdType start_module_Id = NULL_Id;
SizeType module_count = 0;
// Place the error
if ((retvals[thread_num] = ProcessError(error_type, error_Id, error_ref, error_cond,
net_values_FF, net_values_E[i], start_module_Id, forest, thread_num))) continue;
if (start_module_Id == NULL_Id) continue;
// Get list of modules to evaluate
if ((retvals[thread_num] = GetModuleList(start_module_Id, module_count, thread_modules[thread_num]))) continue;
// Evaluate the faulty circuit
if ((retvals[thread_num] = Evaluate(module_count, thread_modules[thread_num], net_values_FF, net_values_E[i], forest, thread_num))) continue;
}
if (retvals[thread_num] != 0) cerr<<"Thread "<<thread_num<<" terminated with error code "<<retvals[thread_num]<<endl;
}
} while(0);
if (retval != 0) cerr<<"Terminated with error code "<<retval<<endl;
return retval;
}
示例7: ReadInput
int ReadInput(int argc, char* argv[])
{
ifstream fin;
int retval = 0;
pair<map<string, IdType>::iterator, bool> ret;
if (argc < 2)
{
cout<<"Error: no input file name"<<endl;
return 1;
}
fin.open(argv[1]);
if (!fin.is_open())
{
cout<<"Error: cannot open input file "<<argv[1]<<endl;
return 2;
}
fin>>num_modules;
modules = new ModuleT*[num_modules];
for (SizeType i=0; i<num_modules; i++)
{
string module_type="", str="";
fin>>module_type;
transform(module_type.begin(), module_type.end(),
module_type.begin(), ::tolower);
getline(fin, str);
//cout<<module_type<<"|"<<str<<endl;
if (module_type == "cross")
modules[i] = new Connecter<IdType, ValueType, SizeType>();
else if (module_type == "not" )
modules[i] = new NotGate <IdType, ValueType, SizeType>();
else if (module_type == "or" )
modules[i] = new OrGate <IdType, ValueType, SizeType>();
else if (module_type == "xor" )
modules[i] = new XorGate <IdType, ValueType, SizeType>();
else if (module_type == "nor" )
modules[i] = new NorGate <IdType, ValueType, SizeType>();
else if (module_type == "and" )
modules[i] = new AndGate <IdType, ValueType, SizeType>();
else if (module_type == "xand" )
modules[i] = new XandGate <IdType, ValueType, SizeType>();
else if (module_type == "nand" )
modules[i] = new NandGate <IdType, ValueType, SizeType>();
else if (module_type == "add" )
modules[i] = new Adder <IdType, ValueType, SizeType>();
else if (module_type == "subtract")
modules[i] = new Subtractor<IdType, ValueType, SizeType>();
else if (module_type == "enable" )
modules[i] = new Enabler <IdType, ValueType, SizeType>();
else if (module_type == "mux" )
modules[i] = new Mux <IdType, ValueType, SizeType>();
else if (module_type == "demux" )
modules[i] = new Demux <IdType, ValueType, SizeType>();
else {
cerr<<"Error ["<<__FILE__<<","<<__LINE__<<"]: "
<<" Module type "<<module_type<<" invalid"<<endl;
return 8;
}
retval = modules[i]->Readin(str);
if (retval != 0) return retval;
if (modules[i]->num_inputs > max_num_inputs) max_num_inputs = modules[i]->num_inputs;
if (modules[i]->num_outputs > max_num_outputs) max_num_outputs = modules[i]->num_outputs;
for (SizeType j=0; j<modules[i]->num_inputs; j++)
{
ret = net_map.insert(
pair<string, IdType>(modules[i]->input_names[j], num_nets));
if (ret.second != false) num_nets++;
modules[i]->input_Ids[j] = ret.first->second;
}
for (SizeType j=0; j<modules[i]->num_outputs; j++)
{
ret = net_map.insert(
pair<string, IdType>(modules[i]->output_names[j], num_nets));
if (ret.second != false) num_nets++;
modules[i]->output_Ids[j] = ret.first->second;
}
//cout<<modules[i]->name << ":" << modules[i]->type;
//for (SizeType j=0; j<modules[i]->num_inputs; j++)
// cout<<" "<<modules[i]->input_names[j]<<","<<modules[i]->input_Ids[j];
//cout<<" -> ";
//for (SizeType j=0; j<modules[i]->num_outputs; j++)
// cout<<" "<<modules[i]->output_names[j]<<","<<modules[i]->output_Ids[j];
//cout<<endl;
}
num_nets = net_map.size();
cout<<"#Modules = "<<num_modules<<" #Nets = "<<num_nets<<endl;
fin>>num_inputs;
net_widths = new SizeType[num_nets];
inputs = new IdType[num_inputs];
memset(net_widths, 0, sizeof(SizeType) * num_nets);
for (SizeType i=0; i<num_nets; i++)
{
string str;
fin>>str;
transform(str.begin(), str.end(), str.begin(), ::tolower);
map<string, IdType>::iterator it = net_map.find(str);
//.........这里部分代码省略.........
示例8: NifStream
void NiLookAtInterpolator::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const {
//--BEGIN PRE-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--//
NiInterpolator::Write( out, link_map, info );
NifStream( unknownShort, out, info );
if ( info.version < VER_3_3_0_13 ) {
WritePtr32( &(*lookAt), out );
} else {
if ( lookAt != NULL ) {
map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(lookAt) );
if (it != link_map.end()) {
NifStream( it->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
NifStream( target, out, info );
NifStream( translation, out, info );
NifStream( rotation, out, info );
NifStream( scale, out, info );
if ( info.version < VER_3_3_0_13 ) {
WritePtr32( &(*unknownLink1), out );
} else {
if ( unknownLink1 != NULL ) {
map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(unknownLink1) );
if (it != link_map.end()) {
NifStream( it->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
if ( info.version < VER_3_3_0_13 ) {
WritePtr32( &(*unknownLink2), out );
} else {
if ( unknownLink2 != NULL ) {
map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(unknownLink2) );
if (it != link_map.end()) {
NifStream( it->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
if ( info.version < VER_3_3_0_13 ) {
WritePtr32( &(*unknownLink3), out );
} else {
if ( unknownLink3 != NULL ) {
map<NiObjectRef,unsigned int>::const_iterator it = link_map.find( StaticCast<NiObject>(unknownLink3) );
if (it != link_map.end()) {
NifStream( it->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
//--BEGIN POST-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--//
}
示例9: BSON
/* ****************************************************************************
*
* addTriggeredSubscriptions -
*/
static bool addTriggeredSubscriptions
(
ContextRegistration cr,
map<string, TriggeredSubscription*>& subs,
std::string& err,
std::string tenant
)
{
BSONArrayBuilder entitiesNoPatternA;
std::vector<std::string> idJsV;
std::vector<std::string> typeJsV;
for (unsigned int ix = 0; ix < cr.entityIdVector.size(); ++ix)
{
// FIXME: take into account subscriptions with no type
EntityId* enP = cr.entityIdVector[ix];
// The registration of isPattern=true entities is not supported, so we don't include them here
if (enP->isPattern == "false")
{
entitiesNoPatternA.append(BSON(CASUB_ENTITY_ID << enP->id <<
CASUB_ENTITY_TYPE << enP->type <<
CASUB_ENTITY_ISPATTERN << "false"));
idJsV.push_back(enP->id);
typeJsV.push_back(enP->type);
}
}
BSONArrayBuilder attrA;
for (unsigned int ix = 0; ix < cr.contextRegistrationAttributeVector.size(); ++ix)
{
ContextRegistrationAttribute* craP = cr.contextRegistrationAttributeVector[ix];
attrA.append(craP->name);
}
BSONObjBuilder queryNoPattern;
queryNoPattern.append(CASUB_ENTITIES, BSON("$in" << entitiesNoPatternA.arr()));
if (attrA.arrSize() > 0)
{
// If we don't do this checking, the {$in: [] } in the attribute name part will
// make the query fail
//
// queryB.append(CASUB_ATTRS, BSON("$in" << attrA.arr()));
queryNoPattern.append("$or", BSON_ARRAY(
BSON(CASUB_ATTRS << BSON("$in" << attrA.arr())) <<
BSON(CASUB_ATTRS << BSON("$size" << 0))));
}
else
{
queryNoPattern.append(CASUB_ATTRS, BSON("$size" << 0));
}
queryNoPattern.append(CASUB_EXPIRATION, BSON("$gt" << (long long) getCurrentTime()));
//
// This is JavaScript code that runs in MongoDB engine. As far as I know, this is the only
// way to do a "reverse regex" query in MongoDB (see
// http://stackoverflow.com/questions/15966991/mongodb-reverse-regex/15989520).
// Note that although we are using a isPattern=true in the MongoDB query besides $where, we
// also need to check that in the if statement in the JavaScript function given that a given
// sub document could include both isPattern=true and isPattern=false documents
//
std::string idJsString = "[ ";
for (unsigned int ix = 0; ix < idJsV.size(); ++ix)
{
if (ix != idJsV.size() - 1)
{
idJsString += "\""+idJsV[ix]+ "\" ,";
}
else
{
idJsString += "\"" +idJsV[ix]+ "\"";
}
}
idJsString += " ]";
std::string typeJsString = "[ ";
for (unsigned int ix = 0; ix < typeJsV.size(); ++ix)
{
if (ix != typeJsV.size() - 1)
{
typeJsString += "\"" +typeJsV[ix] + "\" ,";
}
else
{
typeJsString += "\"" + typeJsV[ix] + "\"";
}
}
typeJsString += " ]";
std::string function = std::string("function()") +
"{" +
//.........这里部分代码省略.........
示例10: NifStream
void NiBoneLODController::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const {
//--BEGIN PRE-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--//
NiTimeController::Write( out, link_map, info );
numShapeGroups2 = (unsigned int)(shapeGroups2.size());
numShapeGroups = (unsigned int)(shapeGroups1.size());
numNodeGroups = (unsigned int)(nodeGroups.size());
NifStream( unknownInt1, out, info );
NifStream( numNodeGroups, out, info );
NifStream( numNodeGroups2, out, info );
for (unsigned int i1 = 0; i1 < nodeGroups.size(); i1++) {
nodeGroups[i1].numNodes = (unsigned int)(nodeGroups[i1].nodes.size());
NifStream( nodeGroups[i1].numNodes, out, info );
for (unsigned int i2 = 0; i2 < nodeGroups[i1].nodes.size(); i2++) {
if ( info.version < VER_3_3_0_13 ) {
NifStream( (unsigned int)&(*nodeGroups[i1].nodes[i2]), out, info );
} else {
if ( nodeGroups[i1].nodes[i2] != NULL ) {
NifStream( link_map.find( StaticCast<NiObject>(nodeGroups[i1].nodes[i2]) )->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
};
};
if ( info.version <= 0x0A000100 ) {
NifStream( numShapeGroups, out, info );
for (unsigned int i2 = 0; i2 < shapeGroups1.size(); i2++) {
shapeGroups1[i2].numLinkPairs = (unsigned int)(shapeGroups1[i2].linkPairs.size());
NifStream( shapeGroups1[i2].numLinkPairs, out, info );
for (unsigned int i3 = 0; i3 < shapeGroups1[i2].linkPairs.size(); i3++) {
if ( info.version < VER_3_3_0_13 ) {
NifStream( (unsigned int)&(*shapeGroups1[i2].linkPairs[i3].shape), out, info );
} else {
if ( shapeGroups1[i2].linkPairs[i3].shape != NULL ) {
NifStream( link_map.find( StaticCast<NiObject>(shapeGroups1[i2].linkPairs[i3].shape) )->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
if ( info.version < VER_3_3_0_13 ) {
NifStream( (unsigned int)&(*shapeGroups1[i2].linkPairs[i3].skinInstance), out, info );
} else {
if ( shapeGroups1[i2].linkPairs[i3].skinInstance != NULL ) {
NifStream( link_map.find( StaticCast<NiObject>(shapeGroups1[i2].linkPairs[i3].skinInstance) )->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
};
};
NifStream( numShapeGroups2, out, info );
for (unsigned int i2 = 0; i2 < shapeGroups2.size(); i2++) {
if ( info.version < VER_3_3_0_13 ) {
NifStream( (unsigned int)&(*shapeGroups2[i2]), out, info );
} else {
if ( shapeGroups2[i2] != NULL ) {
NifStream( link_map.find( StaticCast<NiObject>(shapeGroups2[i2]) )->second, out, info );
} else {
NifStream( 0xFFFFFFFF, out, info );
}
}
};
};
//--BEGIN POST-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--//
}
示例11: getPackData
PackData getPackData(const string& mId) { return packDataMap.find(mId)->second; }
示例12: getProfilesSize
int getProfilesSize() { return profileDataMap.size(); }
示例13: getStyleData
StyleData getStyleData(const string& mId) { return styleDataMap.find(mId)->second; }
示例14: df_autodump_destroy_item
command_result df_autodump_destroy_item(color_ostream &out, vector <string> & parameters)
{
// HOTKEY COMMAND; CORE ALREADY SUSPENDED
if (!parameters.empty())
return CR_WRONG_USAGE;
df::item *item = Gui::getSelectedItem(out);
if (!item)
return CR_FAILURE;
// Allow undoing the destroy
if (world->frame_counter != last_frame)
{
last_frame = world->frame_counter;
pending_destroy.clear();
}
if (pending_destroy.count(item->id))
{
df::item_flags old_flags = pending_destroy[item->id];
pending_destroy.erase(item->id);
item->flags.bits.garbage_colect = false;
item->flags.bits.hidden = old_flags.bits.hidden;
item->flags.bits.dump = old_flags.bits.dump;
item->flags.bits.forbid = old_flags.bits.forbid;
return CR_OK;
}
// Check the item is good to destroy
if (item->flags.bits.garbage_colect)
{
out.printerr("Item is already marked for destroy.\n");
return CR_FAILURE;
}
if (item->flags.bits.construction ||
item->flags.bits.in_building ||
item->flags.bits.artifact1)
{
out.printerr("Choosing not to destroy buildings, constructions and artifacts.\n");
return CR_FAILURE;
}
for (size_t i = 0; i < item->itemrefs.size(); i++)
{
df::general_ref *ref = item->itemrefs[i];
if (ref->getType() == general_ref_type::UNIT_HOLDER)
{
out.printerr("Choosing not to destroy items in unit inventory.\n");
return CR_FAILURE;
}
}
// Set the flags
pending_destroy[item->id] = item->flags;
item->flags.bits.garbage_colect = true;
item->flags.bits.hidden = true;
item->flags.bits.dump = true;
item->flags.bits.forbid = true;
return CR_OK;
}
示例15: get
Variant get(const char* set, const char* key) const {
auto it = m_database.find(set);
return (it == m_database.end() ? Variant() : it->second->get(key));
}