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


C++ StringHash类代码示例

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


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

示例1: main

int main()
{
    StringListTest t1;
    StringHashTest t2;
    QTest::qExec(&t1);
    QTest::qExec(&t2);


    RandomFunction f[3];
    StringHash h;
    h.setFunc(&f[0]);

    int answer = -1;
    int x = 0;
    string s;

    cout << "Commands:\n0 - exit\n";
    cout << "1 - add string to hash\n";
    cout << "2 - remove string from hash\n";
    cout << "3 - find string from hash\n";
    cout << "4 - get status\n";
    cout << "5 - set func(1..3)\n";

    while (answer != 0)
    {
        cout << "Command: ";
        cin >> answer;
        if (answer == 1)
        {
            cout << "Input string\n";
            cin >> s;
            h.add(s);

        }
        else if (answer == 2)
开发者ID:MrKuznetsov,项目名称:hw-cpp,代码行数:35,代码来源:main.cpp

示例2: isValid

bool isValid(StringHash &aHS, StringHash &bHS, int L){
  vector<u64> as = aHS.getAll(L);
  vector<u64> bs = bHS.getAll(L); 
  sort(as.begin(), as.end());
  for (size_t i = 0; i < bs.size(); i++){
    if (binary_search(as.begin(), as.end(), bs[i])) return true;
  }
  return false;
}
开发者ID:LiaoZhuo,项目名称:Practice,代码行数:9,代码来源:poj2774_Long_Long_Message_hash.cpp

示例3: crearConfigServer

/**
crearConfigServer
@param past: Puerto Programa Administrador - Servidor de Transacciones.
@param pcst: Puerto Programa Cliente - Servidor de Transacciones.
@param maxClients: Numero maximo de clientes.
@param bdNombre: Nombre de la base de datos.
@param bdDriver: Nombre del driver.
@param bdHost: Nombre del host.
@param bdPuerto: Nombre del puerto.
@param usuario: Nombre de usuario.
@param password: Password de usuario.
*/
QPDocumentoXML SbXmlConfig::crearConfigServer(StringHash argumentos)
{
	QPDocumentoXML conf;
	QDomElement raiz = conf.createElement( "QPSConfig" );
	conf.appendChild( raiz );
	
	QDomElement puertoAST = conf.createElement("PuertoAST");
	QDomText pastTxt = conf.createTextNode( *argumentos.find("PuertoAST") );
	puertoAST.appendChild(pastTxt);
	raiz.appendChild(puertoAST);
	
	QDomElement puertoCST = conf.createElement("PuertoCST");
	QDomText pcstTxt = conf.createTextNode(*argumentos.find("PuertoCST") );
	puertoCST.appendChild(pcstTxt);
	raiz.appendChild(puertoCST);

	QDomElement clientes = conf.createElement("MaxClients");
	QDomText mcTxt = conf.createTextNode(*argumentos.find("MaxClients"));
	clientes.appendChild(mcTxt);
	raiz.appendChild(clientes);
	
	QDomElement conexion = conf.createElement("QPConexion");
	raiz.appendChild(conexion);
	
	QDomElement bd = conf.createElement("QPBD");
	conexion.appendChild(bd);
	
	QDomElement bdname = conf.createElement("bdnombre");
	QDomText bdnameTxt = conf.createTextNode(*argumentos.find("bdnombre"));
	bdname.appendChild(bdnameTxt);
	bd.appendChild(bdname);
			
	QDomElement bddriver = conf.createElement("bddriver");
	QDomText bddriverTxt = conf.createTextNode(*argumentos.find("bddriver"));
	bddriver.appendChild(bddriverTxt);
	bd.appendChild(bddriver);

	QDomElement bdhost = conf.createElement("bdhost");
	QDomText bdhostTxt = conf.createTextNode(*argumentos.find("bdhost"));
	bdhost.appendChild(bdhostTxt);
	bd.appendChild(bdhost);
	
	QDomElement bdpuerto = conf.createElement("bdpuerto");
	QDomText bdpuertoTxt = conf.createTextNode(*argumentos.find("bdpuerto"));
	bdpuerto.appendChild(bdpuertoTxt);
	bd.appendChild(bdpuerto);	
		
	QDomElement user = conf.createElement("usuario");
	QDomText usuarioTxt = conf.createTextNode(*argumentos.find("usuario"));
	user.appendChild(usuarioTxt);
	bd.appendChild(user);
	
	QDomElement pass = conf.createElement("password");
	QDomText passTxt = conf.createTextNode(*argumentos.find("password"));
	pass.appendChild(passTxt);
	bd.appendChild(pass);
		
	return conf;
}
开发者ID:BackupTheBerlios,项目名称:qapital-svn,代码行数:71,代码来源:sbxmlconfig.cpp

示例4: GetAvailablePlugins

void PluginFrame::OnPluginframeBtnOpenClick( wxCommandEvent& event )
{
////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLUGINFRAME_BTN_OPEN in PluginFrame.
    // Before editing this code, remove the block markers.
    // wxMessageBox(_("To be implemented"));

    StringHash pluginHash = GetAvailablePlugins();

    // explicit type cast to avoid warning on conversion from size_t to int;
    // we reckon we'll never have over 4 billion (!) plugins.
    int n_pluginLibrary = (int)pluginHash.size();

    if(n_pluginLibrary == 0)
    {
        wxMessageBox(NO_PLUGIN_FOUND);
    }
    else
    {
        //
        wxString *choices = new wxString [n_pluginLibrary];

        //
        StringHash::iterator j = pluginHash.begin();
        for(int i = 0; i < n_pluginLibrary; i++, j++)
        {
            choices[i] = j->first;

            if (m_pluginSelected == choices[i])
                m_indexPlugin = i;
        }

        //
        wxSingleChoiceDialog dialog(this,
                                    CHOOSE_PLUGIN_CAPTION,
                                    CHOOSE_PLUGIN,
                                    n_pluginLibrary, choices);

        //dialog.SetSelection(m_indexPlugin);

        if (dialog.ShowModal() == wxID_OK)
        {
            wxString choice = choices[dialog.GetSelection()];
            //Hide();	// done so that there is no more than one instance of this window visible at any time

            LoadPlugin(pluginHash[choice]);
        }
        // Delete the choices (after the dialog modal, no more need of them)
        delete [] choices;
    }

////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PLUGINFRAME_BTN_OPEN in PluginFrame.
}
开发者ID:heineck,项目名称:tests,代码行数:52,代码来源:PluginFrame.cpp

示例5: splitStyle

StringHash Tools::splitStyle(const QString &style)
{
    StringHash hash;
    if (style.isEmpty())
        return hash;
    QStringList list = removeEdgeSpaces(style).split(";", QString::SkipEmptyParts);
    for (int i = 0; i < list.count(); ++i) {
        QString attr = list.at(i);
        int pos = attr.indexOf(QLatin1Char(':'));
        if (pos != -1)
            hash.insert(removeEdgeSpaces(attr.mid(0, pos)), removeEdgeSpaces(attr.mid(pos+1)));
    }
    return hash;
}
开发者ID:larscwallin,项目名称:SVGCleaner,代码行数:14,代码来源:tools.cpp

示例6: RelativeDirectoryFileList

// DirPath should by a directory with a trailing slash.
// Returns all files in all search paths, as unique relative paths.
// Subdirectories will have a trailing slash.
// All files and directories that start with . are skipped.
StringHash< String > RelativeDirectoryFileList( const Array< String > & searchPaths, const char * RelativeDirPath )
{
	//Check each of the mirrors in searchPaths and build up a list of unique strings
	StringHash< String >	uniqueStrings;

	const int numSearchPaths = searchPaths.GetSizeI();
	for ( int index = 0; index < numSearchPaths; ++index )
	{
		const String fullPath = searchPaths[index] + String( RelativeDirPath );

		DIR * dir = opendir( fullPath.ToCStr() );
		if ( dir != NULL )
		{
			struct dirent * entry;
			while ( ( entry = readdir( dir ) ) != NULL )
			{
				if ( entry->d_name[ 0 ] == '.' )
				{
					continue;
				}
				if ( entry->d_type == DT_DIR )
				{
					String s( RelativeDirPath );
					s += entry->d_name;
					s += "/";
					uniqueStrings.SetCaseInsensitive( s, s );
				}
				else if ( entry->d_type == DT_REG )
				{
					String s( RelativeDirPath );
					s += entry->d_name;
					uniqueStrings.SetCaseInsensitive( s, s );
				}
			}
			closedir( dir );
		}
	}

	return uniqueStrings;
}
开发者ID:beijingkaka,项目名称:shellspace,代码行数:44,代码来源:VrCommon.cpp

示例7: GetScene

void Node::SetNetParentAttr(const PODVector<unsigned char>& value)
{
    Scene* scene = GetScene();
    if (!scene)
        return;

    MemoryBuffer buf(value);
    // If nothing in the buffer, parent is the root node
    if (buf.IsEof())
    {
        scene->AddChild(this);
        return;
    }

    unsigned baseNodeID = buf.ReadNetID();
    Node* baseNode = scene->GetNode(baseNodeID);
    if (!baseNode)
    {
        LOGWARNING("Failed to find parent node " + String(baseNodeID));
        return;
    }

    // If buffer contains just an ID, the parent is replicated and we are done
    if (buf.IsEof())
        baseNode->AddChild(this);
    else
    {
        // Else the parent is local and we must find it recursively by name hash
        StringHash nameHash = buf.ReadStringHash();
        Node* parentNode = baseNode->GetChild(nameHash, true);
        if (!parentNode)
            LOGWARNING("Failed to find parent node with name hash " + nameHash.ToString());
        else
            parentNode->AddChild(this);
    }
}
开发者ID:eberan,项目名称:urho3d_old_mirror,代码行数:36,代码来源:Node.cpp

示例8: addComponent

void SceneNode::addComponent(Component* component)
{
	StringHash type = component->getType();

	if (hasComponent(type))
	{
		Logger::warn("Scene node " + name_ + " has already component of type " + std::to_string(type.getValue()));
		return;
	}

	components_[type] = component;

	component->node_ = this;
	component->onNodeSet();
}
开发者ID:xThaid,项目名称:Xi,代码行数:15,代码来源:sceneNode.cpp

示例9: if

StringHash StringHashRegister::RegisterString(const StringHash& hash, const char* string)
{
    if (mutex_)
        mutex_->Acquire();

    auto iter = map_.find(hash);
    if (iter == map_.end())
    {
        map_[hash] = string;
    }
    else if (iter->compare(string, Qt::CaseInsensitive) != 0)
    {
        URHO3D_LOGWARNING(QString::asprintf("StringHash collision detected! Both \"%s\" and \"%s\" have hash #%s",
            string, qPrintable(*iter), qPrintable(hash.ToString())));
    }

    if (mutex_)
        mutex_->Release();

    return hash;
}
开发者ID:nemerle,项目名称:lutefisk3d,代码行数:21,代码来源:StringHashRegister.cpp

示例10: if

StringHash StringHashRegister::RegisterString(const StringHash& hash, const char* string)
{
    if (mutex_)
        mutex_->Acquire();

    auto iter = map_.Find(hash);
    if (iter == map_.End())
    {
        map_.Populate(hash, string);
    }
    else if (iter->second_.Compare(string, false) != 0)
    {
        URHO3D_LOGWARNINGF("StringHash collision detected! Both \"%s\" and \"%s\" have hash #%s",
            string, iter->second_.CString(), hash.ToString().CString());
    }

    if (mutex_)
        mutex_->Release();

    return hash;
}
开发者ID:Nyt0x,项目名称:Urho3D,代码行数:21,代码来源:StringHashRegister.cpp

示例11: RemovePass

void Technique::RemovePass(StringHash type)
{
    passes_.Erase(type.Value());
}
开发者ID:aster2013,项目名称:Urho3D,代码行数:4,代码来源:Technique.cpp

示例12: nameHash

bool BackgroundLoader::QueueResource(StringHash type, const ea::string& name, bool sendEventOnFailure, Resource* caller)
{
    StringHash nameHash(name);
    ea::pair<StringHash, StringHash> key = ea::make_pair(type, nameHash);

    MutexLock lock(backgroundLoadMutex_);

    // Check if already exists in the queue
    if (backgroundLoadQueue_.find(key) != backgroundLoadQueue_.end())
        return false;

    BackgroundLoadItem& item = backgroundLoadQueue_[key];
    item.sendEventOnFailure_ = sendEventOnFailure;

    // Make sure the pointer is non-null and is a Resource subclass
    item.resource_ = DynamicCast<Resource>(owner_->GetContext()->CreateObject(type));
    if (!item.resource_)
    {
        URHO3D_LOGERROR("Could not load unknown resource type " + type.ToString());

        if (sendEventOnFailure && Thread::IsMainThread())
        {
            using namespace UnknownResourceType;

            VariantMap& eventData = owner_->GetEventDataMap();
            eventData[P_RESOURCETYPE] = type;
            owner_->SendEvent(E_UNKNOWNRESOURCETYPE, eventData);
        }

        backgroundLoadQueue_.erase(key);
        return false;
    }

    URHO3D_LOGDEBUG("Background loading resource " + name);

    item.resource_->SetName(name);
    item.resource_->SetAsyncLoadState(ASYNC_QUEUED);

    // If this is a resource calling for the background load of more resources, mark the dependency as necessary
    if (caller)
    {
        ea::pair<StringHash, StringHash> callerKey = ea::make_pair(caller->GetType(), caller->GetNameHash());
        auto j = backgroundLoadQueue_.find(
            callerKey);
        if (j != backgroundLoadQueue_.end())
        {
            BackgroundLoadItem& callerItem = j->second;
            item.dependents_.insert(callerKey);
            callerItem.dependencies_.insert(key);
        }
        else
            URHO3D_LOGWARNING("Resource " + caller->GetName() +
                       " requested for a background loaded resource but was not in the background load queue");
    }

    // Start the background loader thread now
    if (!IsStarted())
        Run();

    return true;
}
开发者ID:rokups,项目名称:Urho3D,代码行数:61,代码来源:BackgroundLoader.cpp

示例13: WriteStringHash

bool Serializer::WriteStringHash(const StringHash& value)
{
    return WriteUInt(value.Value());
}
开发者ID:cleavetv,项目名称:Urho3D,代码行数:4,代码来源:Serializer.cpp

示例14: main


//.........这里部分代码省略.........
        fprintf(baseCalls, "##minMapQuality=%d\n", mapQuality);
        fprintf(baseCalls, "##minPosterior=%.4f\n", posterior);
        fprintf(baseCalls, "##INFO=<ID=DP,Number=1,Type=Integer,Description=\"Total Depth\">\n");
        fprintf(baseCalls, "##INFO=<ID=MQ,Number=1,Type=Integer,Description=\"Root Mean Squared Mapping Quality\">\n");
        fprintf(baseCalls, "##INFO=<ID=NS,Number=1,Type=Integer,Description=\"Number of samples with coverage\">\n");
        fprintf(baseCalls, "##INFO=<ID=AN,Number=1,Type=Integer,Description=\"Total number of alleles (with coverage)\">\n");
        fprintf(baseCalls, "##INFO=<ID=AC,Number=.,Type=Integer,Description=\"Alternative allele count (with coverage)\">\n");
        fprintf(baseCalls, "##INFO=<ID=AF,Number=.,Type=Float,Description=\"Alternate allele frequency\">\n");
        fprintf(baseCalls, "##INFO=<ID=AB,Number=1,Type=Float,Description=\"Estimated allele balance between the alleles\">\n");
	if ( mapQuality > 0 ) {
	  fprintf(baseCalls, "##FILTER=<ID=mq%d,Description=\"Mapping Quality less than %d\">\n",mapQuality,mapQuality);
	}
	if ( minTotalDepth > 1 ) {
	  fprintf(baseCalls, "##FILTER=<ID=dp%d,Description=\"Total Read Depth less than %d\">\n",minTotalDepth,minTotalDepth);
	}
	if ( minTotalDepth < INT_MAX ) {
	  fprintf(baseCalls, "##FILTER=<ID=DP%d,Description=\"Total Read Depth greater than %d\">\n",maxTotalDepth,maxTotalDepth);
	}
        fprintf(baseCalls, "##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Most Likely Genotype\">\n");
        fprintf(baseCalls, "##FORMAT=<ID=GQ,Number=1,Type=Integer,Description=\"Genotype Call Quality\">\n");
        fprintf(baseCalls, "##FORMAT=<ID=DP,Number=1,Type=Integer,Description=\"Read Depth\">\n");
        fprintf(baseCalls, "##FORMAT=<ID=PL,Number=3,Type=Integer,Description=\"Genotype Likelihoods for Genotypes 0/0,0/1,1/1\">\n");
        fprintf(baseCalls, "##FORMAT=<ID=PL3,Number=6,Type=Integer,Description=\"Genotype Likelihoods for Genotypes 0/0,0/1,1/1,0/2,1/2,2/2\">\n");
        fprintf(baseCalls, "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT");
        for (int i = 0; i < n; i++)
            fprintf(baseCalls, "\t%s", ped.count ?
                    (const char *) (ped[i].famid + ":" + ped[i].pid) :
                    (const char *) aliases.GetAlias(argv[i]));

        fprintf(baseCalls, "\n");
    }

    StringArray buffer, tokens;
    StringHash  positions;

    buffer.Read(positionfile);

    for (int i = 0; i < buffer.Length(); i++)
    {
        tokens.ReplaceTokens(buffer[i], " \t:");

        if (tokens.Length() != 2) continue;

        positions.Add(tokens[0] + ":" + (int(tokens[1].AsInteger() - 1)));
    }

    int chromosomeType = 0;

    while (glf[firstGlf].NextSection())
    {
        for (int i = firstGlf + 1; i < n; i++)
        {
            if (glf[i].isStub) continue;

            glf[i].NextSection();

            if (glf[firstGlf].maxPosition != glf[i].maxPosition || glf[firstGlf].label != glf[i].label)
            {
                error("Genotype files '%s' and '%s' are not compatible ...\n"
                      "    File '%s' has section %s with %d entries ...\n"
                      "    File '%s' section %s with %d entries ...\n",
                      ped.count ? (const char *) ped[firstGlf].strings[0] : argv[firstGlf],
                      ped.count ? (const char *) ped[i].strings[0] : argv[i],
                      ped.count ? (const char *) ped[firstGlf].strings[0] : argv[firstGlf],
                      (const char *) glf[firstGlf].label, glf[firstGlf].maxPosition,
                      ped.count ? (const char *) ped[i].strings[0] : argv[i],
开发者ID:aminzia,项目名称:statgen,代码行数:67,代码来源:Main.cpp

示例15: urho_stringhash_from_string

	DllExport
	unsigned urho_stringhash_from_string (const char *p)
	{
		StringHash foo (p);
		return foo.Value ();
	}
开发者ID:corefan,项目名称:urho,代码行数:6,代码来源:glue.cpp


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