int main()
{

	Set<string> names;
	names.Insert("A1");
	names.Insert("A2");
	names.Insert("A3");
	names.Insert("A4");


	double defaultValue(0.0);

	AssocArray<double, string> myAssocArray(names, defaultValue);
	print(myAssocArray);
	myAssocArray["A4"] = 99.99;
	print(myAssocArray);


	// Test other functions
	AssocArray<double, string> myAssocArray2(myAssocArray);
	print(myAssocArray2);

	AssocArray<double, string> myAssocArray3 = myAssocArray;
	print(myAssocArray3);

	AssocArray<double, string> myAssocArray4(names, 3.14);
	print(myAssocArray4);

	return 0;
}
Example #2
0
AutoPtr< List<String> > TokenWatcher::DumpInternal()
{
    AutoPtr< List<String> > a = new List<String>;
    {
        AutoLock lock(mLock);
        Set<AutoPtr<IBinder> > keys;
        HashMap<AutoPtr<IBinder>, AutoPtr<Death> >::Iterator iter = mTokens.Begin();
        for (; iter != mTokens.End(); ++iter) {
            keys.Insert(iter->mFirst);
        }
        StringBuilder sb("Token count: ");
        sb += mTokens.GetSize();
        a->PushBack(sb.ToString());
        Int32 i = 0;
        Set<AutoPtr<IBinder> >::Iterator iter2 = keys.Begin();
        AutoPtr<IBinder> b;
        for (; iter2 != keys.End(); ++iter) {
            StringBuilder sb2("[");
            sb2 += i;
            sb2 += "] ";
            sb2 += mTokens[b]->mTag;
            sb2 += " - ";
            String bstr;
            b->ToString(&bstr);
            sb2 += bstr;
            a->PushBack(sb2.ToString());
            i++;
        }
    }
    return a;
}
Example #3
0
/*--------------------------------------------------------------------------------------------*/
void GdlGlyphDefn::GetMachineClasses(FsmMachineClass ** ppfsmcAssignments,
	Set<FsmMachineClass *> & setpfsmc)
{
	for (int iw = 0; iw < m_vwGlyphIDs.Size(); iw++)
	{
		utf16 wGlyphID = m_vwGlyphIDs[iw];
		FsmMachineClass * pfsmc = ppfsmcAssignments[wGlyphID];
		if (!setpfsmc.IsMember(pfsmc))
			setpfsmc.Insert(pfsmc);
	}
}
Example #4
0
/*----------------------------------------------------------------------------------------------
	Check for various error conditions.
----------------------------------------------------------------------------------------------*/
bool GdlFeatureDefn::ErrorCheck()
{
	if (m_fStdLang)
	{
		Assert(m_vpfset.Size() == 0);
		m_fIDSet = true;
		return true;
	}

	//	Feature with no ID: fatal error
	if (m_fIDSet == false)
	{
		g_errorList.AddError(3158, this,
			"No id specified for feature ",
			m_staName);
		m_fFatalError = true;
		return false;
	}

	//	Duplicate IDs in feature settings: fatal error
	Set<int> setnIDs;
	for (int ifset = 0; ifset < m_vpfset.Size(); ++ifset)
	{
		int nValue = m_vpfset[ifset]->m_nValue;
		if (setnIDs.IsMember(nValue))
		{
			g_errorList.AddError(3159, m_vpfset[ifset],
				"Duplicate feature setting values in ",
				m_staName);
			m_fFatalError = true;
			return false;
		}
		setnIDs.Insert(nValue);
	}

	//	Feature with only one setting: warning
	if (m_vpfset.Size() == 1)
		g_errorList.AddWarning(3525, this,
			"Only one setting given for feature ",
			m_staName);

	return true;
}
bool GdlRenderer::PreCompileFeatures(GrcManager * pcman, GrcFont * pfont, int * pfxdFeatVersion)
{
	*pfxdFeatVersion = 0x00010000;

	int nInternalID = 0;

	Set<unsigned int> setID;

	for (int ipfeat = 0; ipfeat < m_vpfeat.Size(); ipfeat++)
	{
		GdlFeatureDefn * pfeat = m_vpfeat[ipfeat];
		unsigned int nID = pfeat->ID();
		if (setID.IsMember(nID))
		{
			char rgch[20];
			if (nID > 0x00FFFFFF)
			{
				char rgchID[5];
				memcpy(rgch, &nID, 4);
				rgchID[0] = rgch[3]; rgchID[1] = rgch[2]; rgchID[2] = rgch[1]; rgchID[3] = rgch[0];
				rgchID[4] = 0;
				StrAnsi staTmp = "'";
				staTmp.Append(rgchID);
				staTmp.Append("'");
				memcpy(rgch, staTmp.Chars(), staTmp.Length() + 1);
			}
			else
				itoa(nID, rgch, 10);
			g_errorList.AddError(3152, pfeat, "Duplicate feature ID: ", rgch);
		}
		else
			setID.Insert(nID);

		if (pfeat->ErrorCheck())
		{
			pfeat->SetStdStyleFlag();
			pfeat->FillInBoolean(pcman->SymbolTable());
			pfeat->ErrorCheckContd();
			pfeat->CalculateDefault();
			pfeat->AssignInternalID(nInternalID);
			pfeat->RecordDebugInfo();
		}

		if (nID > 0x0000FFFF)
			*pfxdFeatVersion = 0x00020000;

		nInternalID++;
	}

	if (m_vpfeat.Size() > kMaxFeatures)
	{
		char rgchMax[20];
		itoa(kMaxFeatures, rgchMax, 10);
		char rgchCount[20];
		itoa(m_vpfeat.Size(), rgchCount, 10);
		g_errorList.AddError(3153, NULL,
			"Number of features (",
			rgchCount,
			") exceeds maximum of ",
			rgchMax);
	}

	return true;
}
Example #6
0
void InitGUI()
{
	// Find available video modes.
	
	video::IVideoModeList *vmList = GetEngine()->GetIrrlichtDevice()->getVideoModeList();
	
	// We ignore the bit depth, as the maximum available is always chosen.
	// (32 bits, when creating the Irrlicht device).
	
	for (s32 i = 0; i < vmList->getVideoModeCount(); i ++)
		videoModes.Insert( vmList->getVideoModeResolution(i) );
	
	for (auto & videoMode : videoModes)
	{
		core::stringw resStr;
		resStr += videoMode.Width;
		resStr += "x";
		resStr += videoMode.Height;
		comboboxScreenRes->addItem(resStr.c_str());
	}
	
	
	// Now we set up the GUI depending on the previously saved settings.
	
	ASSERT( projectSettings["screenWidth"] > 0 );
	ASSERT( projectSettings["screenHeight"] > 0 );
	
	
	if (videoModes.size() == 0)
	{
		WARN << "No video modes were found...";
	}
	else
	{
		if (!selectVideoModeInComboBox( core::dimension2du(projectSettings["screenWidth"],
				projectSettings["screenHeight"]) ))
		{
			// Not found!? Fall back to the project default...
			// This would presumably only occur if the user changed their monitor or something
			// and a previously set video mode was no longer supported.
			NOTE << "VideoMode [" << projectSettings["screenWidth"] << " by " << projectSettings["screenHeight"]
					<< "] not found, falling back to project default...";
			
			// (still need to override the engine settings, to get the engine's default,
			// since the project might not have specified a video mode)
			VariantMap defaultProjectSettings = GetEngine()->GetDefaultSettings();
			override_variantmap(defaultProjectSettings, PROJECT_DEFAULT_SETTINGS());
			
			ASSERT( defaultProjectSettings["screenWidth"] > 0 );
			ASSERT( defaultProjectSettings["screenHeight"] > 0 );
			
			// Attempt to set the default.
			if (!selectVideoModeInComboBox( core::dimension2du(defaultProjectSettings["screenWidth"],
					defaultProjectSettings["screenHeight"]) ))
			{
				NOTE << "Default VideoMode [" << projectSettings["screenWidth"] << " by "
						<< projectSettings["screenHeight"] << "] not found, will use the first in list... ["
						<< videoModes[0].Width << " by " << videoModes[0].Height << "]";
				
				
				// Default is not present either!?
				// SO, just select the first in the list...
				comboboxScreenRes->setSelected(0);
			}
		}
	}
	
	checkboxFullScreen->setChecked( projectSettings["fullScreen"] );
	checkboxShaders->setChecked( projectSettings["shadersEnabled"] );
	checkboxPostProcessing->setChecked( projectSettings["postProcessingEnabled"] );
}