static inline PassRefPtr<StringImpl> addToStringTable(const T& value) { pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable().add<T, HashTranslator>(value); // If the string is newly-translated, then we need to adopt it. // The boolean in the pair tells us if that is so. return addResult.second ? adoptRef(*addResult.first) : *addResult.first; }
PassRefPtr<StringImpl> AtomicString::add(const char* c) { if (!c) return 0; if (!*c) return StringImpl::empty(); pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable().add<const char*, CStringTranslator>(c); if (!addResult.second) return *addResult.first; return adoptRef(*addResult.first); }
void LineGraph::GenrateGraph(sint32 &infoXCount, sint32 &infoYCount, double *** infoGraphData, sint32 category) { infoYCount = 0; infoXCount = 0; AUI_ERRCODE errcode = AUI_ERRCODE_OK; std::auto_ptr<aui_StringTable> stringTable (new aui_StringTable(&errcode, "InfoStrings")); SetXAxisName(stringTable->GetString(6)); SetYAxisName("Power"); double minRound = s_minRound; double curRound = g_turn->GetRound(); double minPower = 0; double maxPower = 10; SetGraphBounds(minRound, curRound, minPower, maxPower); HasIndicator(false); sint32 i; for ( i = 0 ; i < k_MAX_PLAYERS ; i++ ) { if (g_player[i] && (i != PLAYER_INDEX_VANDALS)) { infoYCount++; } } sint32* color = new sint32[infoYCount + g_deadPlayer->GetCount()]; infoYCount = 0; for ( i = 0 ; i < k_MAX_PLAYERS ; i++ ) { if (g_player[i] && (i != PLAYER_INDEX_VANDALS)) { color[infoYCount++] = g_colorSet->ComputePlayerColor(i); } } for ( PointerList<Player>::Walker walk(g_deadPlayer); walk.IsValid(); walk.Next() ) { color[infoYCount++] = g_colorSet->ComputePlayerColor(walk.GetObj()->GetOwner()); } infoXCount = static_cast<sint32>(curRound) - static_cast<sint32>(minRound); if (infoXCount == 0) { RenderGraph(); return; } infoXCount = std::max<sint32>(1, infoXCount); infoYCount = std::max<sint32>(1, infoYCount); Assert(!*infoGraphData); *infoGraphData = new double *[infoYCount]; for (i = 0 ; i < infoYCount; i++) { (*infoGraphData)[i] = new double[infoXCount]; std::fill((*infoGraphData)[i], (*infoGraphData)[i] + infoXCount, 0.0); } sint32 playerCount = 0; for ( i = 0 ; i < k_MAX_PLAYERS ; i++ ) { if (g_player[i] && (i != PLAYER_INDEX_VANDALS)) { for (sint32 round = 0 ; round < infoXCount ; ++round) { sint32 strValue = GetCombinedStrength(*g_player[i]->m_strengths, round, category); (*infoGraphData)[playerCount][round] = strValue; while (strValue > maxPower) maxPower += 10.0; } playerCount++; } } for ( PointerList<Player>::Walker walk2(g_deadPlayer); walk2.IsValid(); walk2.Next() ) { for (sint32 round = 0 ; round < infoXCount ; ++round) { sint32 strValue = GetCombinedStrength(*walk2.GetObj()->m_strengths, round, category); (*infoGraphData)[playerCount][round] = strValue; while (strValue > maxPower) maxPower += 10.0; } playerCount++; } Assert(playerCount == infoYCount); SetLineData(infoYCount, infoXCount, (*infoGraphData), color); SetGraphBounds(minRound, curRound, minPower, maxPower); RenderGraph(); delete color; }