本文整理汇总了C++中map类 的典型用法代码示例。如果您正苦于以下问题:C++ map类的具体用法?C++ map怎么用?C++ map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了map类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:AbhiNki, 项目名称:procon, 代码行数:6, 代码来源:tyama_icpc2013s4A(aizu2619).cpp
示例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);
//.........这里部分代码省略.........
开发者ID:richo, 项目名称:SSVOpenHexagon, 代码行数:101, 代码来源:Assets.cpp
示例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);
}
//.........这里部分代码省略.........
开发者ID:nicmcd, 项目名称:ee382c_final_project, 代码行数:101, 代码来源:TrafficGenerator.cpp
示例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;
}
开发者ID:TacoVox, 项目名称:OpenDaVINCI, 代码行数:76, 代码来源:PointSensor.cpp
示例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;
}
开发者ID:sqxiang, 项目名称:pywsrec, 代码行数:5, 代码来源:LACF.cpp
示例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;
}
开发者ID:sgpyc, 项目名称:EEC283, 代码行数:94, 代码来源:main.cpp
示例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);
//.........这里部分代码省略.........
开发者ID:sgpyc, 项目名称:EEC283, 代码行数:101, 代码来源:main.cpp
示例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--//
}
开发者ID:LogicDragon, 项目名称:niflib, 代码行数:70, 代码来源:NiLookAtInterpolator.cpp
示例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()") +
"{" +
//.........这里部分代码省略.........
开发者ID:Fiware, 项目名称:context.Orion, 代码行数:101, 代码来源:MongoCommonRegister.cpp
示例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--//
}
开发者ID:przemyslaw-szymanski, 项目名称:x-source-engine, 代码行数:69, 代码来源:NiBoneLODController.cpp
示例11: withVariables
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function Name:
// Purpose:
// Inputs:
// Output:
// Notes:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
void ExpressionBuilder::withVariables(const map<string, double> &variableMap) {
for (map<string, double>::const_iterator iter = variableMap.begin(); iter != variableMap.end(); iter++) {
pair<string, double> obj((*iter).first, (*iter).second);
m_variables.insert(obj);
}
}
开发者ID:caolandix, 项目名称:jumpdrive, 代码行数:15, 代码来源:ExpressionBuilder.cpp
示例12: main
int main (int argc, char** argv) {
// cerr << "Before" << endl;
if (argc == 1){
cerr << "Usage: merge_gc-plp " << "<in.plp> <in.gc> > <out.cvgc>\n";
return 0;
}
// cerr << "After" << endl;
string str = argv[1];
ifstream cov_in(str.c_str());
string ctg;
int pos;
char b;
int cov;
site* s;
map<int,site>* sites;
while (cov_in.good()){
getline(cov_in,ctg,'\t');
getline(cov_in,str,'\t');
pos = atoi(str.c_str());
getline(cov_in,str,'\t');
b = str.at(0);
getline(cov_in,str,'\t');
cov = atoi(str.c_str());
getline(cov_in,str);
s = new site;
s->ctg = ctg;
s->pos = pos;
s->b = b;
s->cov = cov;
s->gc = -1.0;
sites = &(table.find(ctg)->second);
if (sites == &(table.end()->second)){
sites = new map<int,site>();
(*sites)[pos] = *s;
table[ctg] = *sites;
order.push_back(ctg);
} else {
(*sites)[pos] = *s;
}
}
str = argv[2];
ifstream gc_in(str.c_str());
double gc;
// while(gc_in.good()){
while(getline(gc_in,ctg,'\t')){ //;
getline(gc_in,str,'\t');
pos = atoi(str.c_str());
getline(gc_in,str);
gc = atof(str.c_str());
sites = &(table.find(ctg)->second);
if (sites == &(table.end()->second)){
sites = new map<int,site>();
s = new site;
s->ctg = ctg;
s->pos = pos;
s->b = '-';
s->cov = 0;
s->gc = gc;
(*sites)[pos] = *s;
table[ctg] = *sites;
order.push_back(ctg);
} else {
s = &(sites->find(pos)->second);
if (s == &(sites->end()->second)){
s = new site;
s->ctg = ctg;
s->pos = pos;
s->b = '-';
s->cov = 0;
s->gc = gc;
(*sites)[pos] = *s;
} else
s->gc = gc;
}
}
list<string>::iterator ctg_it;
map<int,site>::iterator site_it;
cout << "ctg\tpos\tbase\tcov\tgc" << endl;
for (ctg_it = order.begin(); ctg_it != order.end(); ctg_it++){
sites = &(table.find(*ctg_it)->second);
for (site_it = sites->begin(); site_it != sites->end(); site_it++){
s = &(site_it->second);
if (s->complete() || KEEP_ALL)
printSite(*s,cout);
}
}
}
开发者ID:estolle, 项目名称:ngopt, 代码行数:92, 代码来源:merge_gc-plp.cpp
示例13: ProcessGroups
//Process groups by computing percentiles for each item and lo-values for each group
//groups: genes
//lists: a set of different groups. Comparison will be performed on individual list
int ProcessGroups(GROUP_STRUCT *groups, int groupNum, LIST_STRUCT *lists, int listNum, double maxPercentile)
{
int i,j;
int listIndex, index1, index2;
int maxItemPerGroup;
double *tmpF;
double *tmpProb;
bool isallone; // check if all the probs are 1; if yes, do not use accumulation of prob. scores
maxItemPerGroup = 0;
PRINT_DEBUG=1;
for (i=0;i<groupNum;i++){
if (groups[i].itemNum>maxItemPerGroup){
maxItemPerGroup = groups[i].itemNum;
}
}
assert(maxItemPerGroup>0);
tmpF = new double[maxItemPerGroup];
tmpProb = new double [maxItemPerGroup];
for (i=0;i<listNum;i++){
QuicksortF(lists[i].values, 0, lists[i].itemNum-1);
}
for (i=0;i<groupNum;i++){
//Compute percentile for each item
isallone=true;
int validsgs=0;
for (j=0;j<groups[i].itemNum;j++){
if(groups[i].items[j].isChosen==0) continue;
listIndex = groups[i].items[j].listIndex;
index1 = bTreeSearchingF(groups[i].items[j].value-0.000000001, lists[listIndex].values, 0, lists[listIndex].itemNum-1);
index2 = bTreeSearchingF(groups[i].items[j].value+0.000000001, lists[listIndex].values, 0, lists[listIndex].itemNum-1);
groups[i].items[j].percentile = ((double)index1+index2+1)/(lists[listIndex].itemNum*2);
tmpF[validsgs] = groups[i].items[j].percentile;
tmpProb[validsgs]=groups[i].items[j].prob;
if(tmpProb[validsgs]!=1.0){
isallone=false;
}
// save for control sequences
if(UseControlSeq){
string sgname(groups[i].items[j].name);
if(ControlSeqMap.count(sgname)>0){
int sgindex=ControlSeqMap[sgname];
ControlSeqPercentile[sgindex]=tmpF[validsgs];
}
}//end if
validsgs++;
}// end j
if(validsgs<=1){
isallone=true;
}
//printf("Gene: %s\n",groups[i].name);
if(isallone){
ComputeLoValue(tmpF, validsgs, groups[i].loValue, maxPercentile, groups[i].goodsgrnas);
}
else{
ComputeLoValue_Prob(tmpF, validsgs, groups[i].loValue, maxPercentile, tmpProb,groups[i].goodsgrnas);
}
groups[i].isbad=0;
}//end i loop
delete[] tmpF;
delete[] tmpProb;
//check if all control sequences are properly assigned a value
if(UseControlSeq){
for(map<string,int>::iterator mit = ControlSeqMap.begin(); mit != ControlSeqMap.end(); mit++){
if(ControlSeqPercentile[mit->second]<0){
cerr<<"Warning: sgRNA "<<mit->first<<" not found in the ranked list. \n";
//ControlSeqPercentile[mit->second]=0.5;
}
}
}//end UseControlSeq
return 1;
}
开发者ID:yarker, 项目名称:MAGeCK_Repo, 代码行数:86, 代码来源:RRA.cpp
示例14: ComputeFDR
//Compute False Discovery Rate based on uniform distribution
int ComputeFDR(GROUP_STRUCT *groups, int groupNum, double maxPercentile, int numOfRandPass)
{
int i,j,k;
double *tmpPercentile;
int maxItemNum = 0;
int scanPass = numOfRandPass/groupNum+1;
double *randLoValue;
int randLoValueNum;
//WL
double *tmpProb;
double isallone;
for (i=0;i<groupNum;i++){
if (groups[i].itemNum>maxItemNum){
maxItemNum = groups[i].itemNum;
}
}
assert(maxItemNum>0);
//tmpPercentile = (double *)malloc(maxItemNum*sizeof(double));
//tmpProb= (double *)malloc(maxItemNum*sizeof(double));
tmpPercentile=new double[maxItemNum];
tmpProb=new double[maxItemNum];
randLoValueNum = groupNum*scanPass;
assert(randLoValueNum>0);
//randLoValue = (double *)malloc(randLoValueNum*sizeof(double));
randLoValue=new double[randLoValueNum];
randLoValueNum = 0;
PlantSeeds(123456);
PRINT_DEBUG=0;
// set up control sequences
int n_control=0;
double* control_prob_array=NULL;
double ufvalue=0.5;
int rand_ctl_index=0;
int tmp_int;
if(UseControlSeq){
for(map<string,int>::iterator mit = ControlSeqMap.begin(); mit != ControlSeqMap.end(); mit++){
if(ControlSeqPercentile[mit->second]>=0){
n_control++;
}
}
control_prob_array=new double[n_control];
n_control=0;
for(map<string,int>::iterator mit = ControlSeqMap.begin(); mit != ControlSeqMap.end(); mit++){
if(ControlSeqPercentile[mit->second]>=0){
control_prob_array[n_control]=ControlSeqPercentile[mit->second];
n_control++;
}
}
cout<<"Total # control sgRNAs: "<<n_control<<endl;
}
for (i=0;i<scanPass;i++){
for (j=0;j<groupNum;j++){
isallone=true;
int validsgs=0;
for (k=0;k<groups[j].itemNum;k++)
{
if(groups[j].items[k].isChosen==0) continue;
ufvalue=Uniform(0.0, 1.0);
if(UseControlSeq){
rand_ctl_index=(int)(n_control*ufvalue);
if(rand_ctl_index>=n_control) rand_ctl_index=n_control-1;
tmpPercentile[validsgs]=control_prob_array[rand_ctl_index];
}else{
tmpPercentile[validsgs] = ufvalue;
}
tmpProb[validsgs]=groups[j].items[k].prob;
if(tmpProb[validsgs]!=1.0)
{
isallone=false;
}
validsgs++;
} //end for k
if(validsgs<=1)
isallone=true;
if(isallone){
ComputeLoValue(tmpPercentile, validsgs,randLoValue[randLoValueNum], maxPercentile, tmp_int);
}
else
{
ComputeLoValue_Prob(tmpPercentile, validsgs,randLoValue[randLoValueNum], maxPercentile,tmpProb,tmp_int);
}
randLoValueNum++;
}// end for j
}//end for i
//.........这里部分代码省略.........
开发者ID:yarker, 项目名称:MAGeCK_Repo, 代码行数:101, 代码来源:RRA.cpp
示例15: printspare
//To print the entries in spare
void printspare()
{
cout<<"Entries in spare\nrow col value\n";
for(mapiterator=spare.begin();mapiterator!=spare.end();mapiterator++)
cout<<mapiterator->first.first<<" "<<mapiterator->first.second<<" "<<mapiterator->second<<endl;
}
开发者ID:shaileshpb, 项目名称:Spoj_solutions, 代码行数:7, 代码来源:sampleInserter.cpp
示例16: getPackData
PackData getPackData(const string& mId) { return packDataMap.find(mId)->second; }
开发者ID:richo, 项目名称:SSVOpenHexagon, 代码行数:1, 代码来源:Assets.cpp
示例17: getProfilesSize
int getProfilesSize() { return profileDataMap.size(); }
开发者ID:richo, 项目名称:SSVOpenHexagon, 代码行数:1, 代码来源:Assets.cpp
示例18: getStyleData
StyleData getStyleData(const string& mId) { return styleDataMap.find(mId)->second; }
开发者ID:richo, 项目名称:SSVOpenHexagon, 代码行数:1, 代码来源:Assets.cpp
示例19: df_autodump_destroy_item
请发表评论