本文整理汇总了C++中TMap类的典型用法代码示例。如果您正苦于以下问题:C++ TMap类的具体用法?C++ TMap怎么用?C++ TMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRestoreFilename
TMap<FString, FString> PackageAutoSaverJson::LoadRestoreFile()
{
TMap<FString, FString> PackagesThatCanBeRestored;
const FString Filename = GetRestoreFilename(false);
FArchive* const FileAr = IFileManager::Get().CreateFileReader(*Filename);
if(!FileAr)
{
// File doesn't exist; nothing to restore
return PackagesThatCanBeRestored;
}
bool bJsonLoaded = false;
TSharedPtr<FJsonObject> RootObject = MakeShareable(new FJsonObject);
{
TSharedRef<FJsonReader> Reader = FJsonReaderFactory::Create(FileAr);
bJsonLoaded = FJsonSerializer::Deserialize(Reader, RootObject);
FileAr->Close();
}
if(!bJsonLoaded || !RootObject->GetBoolField(TagRestoreEnabled))
{
// File failed to load, or the restore is disabled; nothing to restore
return PackagesThatCanBeRestored;
}
TArray< TSharedPtr<FJsonValue> > PackagesThatCanBeRestoredArray = RootObject->GetArrayField(TagPackages);
for(auto It = PackagesThatCanBeRestoredArray.CreateConstIterator(); It; ++It)
{
TSharedPtr<FJsonObject> EntryObject = (*It)->AsObject();
const FString PackagePathName = EntryObject->GetStringField(TagPackagePathName);
const FString AutoSavePath = EntryObject->GetStringField(TagAutoSavePath);
PackagesThatCanBeRestored.Add(PackagePathName, AutoSavePath);
}
return PackagesThatCanBeRestored;
}
示例2: HandleTicker
bool FRawProfilerSession::HandleTicker( float DeltaTime )
{
#if 0
StatsThreadStats;
Stream;
enum
{
MAX_NUM_DATA_PER_TICK = 30
};
int32 NumDataThisTick = 0;
// Add the data to the mini-view.
for( int32 FrameIndex = CurrentMiniViewFrame; FrameIndex < Stream.FramesInfo.Num(); ++FrameIndex )
{
const FStatsFrameInfo& StatsFrameInfo = Stream.FramesInfo[FrameIndex];
// Convert from cycles to ms.
TMap<uint32, float> ThreadMS;
for( auto InnerIt = StatsFrameInfo.ThreadCycles.CreateConstIterator(); InnerIt; ++InnerIt )
{
ThreadMS.Add( InnerIt.Key(), StatMetaData->ConvertCyclesToMS( InnerIt.Value() ) );
}
// Pass the reference to the stats' metadata.
// @TODO yrx 2014-04-03 Figure out something better later.
OnAddThreadTime.ExecuteIfBound( FrameIndex, ThreadMS, StatMetaData );
//CurrentMiniViewFrame++;
NumDataThisTick++;
if( NumDataThisTick > MAX_NUM_DATA_PER_TICK )
{
break;
}
}
#endif // 0
return true;
}
示例3: BOOST_AUTO_TEST_CASE_TEMPLATE
/**
* insert
*/
BOOST_AUTO_TEST_CASE_TEMPLATE(stest_insert, TMap, test_types) {
// insert x values, insert them again, check values
using char_tt = typename TMap::char_type;
const size_t nb_values = 100000;
TMap set;
typename TMap::iterator it;
bool inserted;
for(size_t i = 0; i < nb_values; i++) {
std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
BOOST_CHECK(inserted);
}
BOOST_CHECK_EQUAL(set.size(), nb_values);
for(size_t i = 0; i < nb_values; i++) {
std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
BOOST_CHECK(!inserted);
}
for(size_t i = 0; i < nb_values; i++) {
it = set.find(utils::get_key<char_tt>(i));
BOOST_CHECK(it != set.end());
BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
}
for(auto it = set.begin(); it != set.end(); ++it) {
auto it_find = set.find(it.key());
BOOST_CHECK(it_find != set.end());
BOOST_CHECK_EQUAL(it_find.key(), it.key());
}
}
示例4: ldvcellValidaObj
void ldvcellValidaObj(RayCell c, const TMap & map, Objetos_t & obj, int nivelMech){
THex * infoCell = NULL;
THex * infoCellAlt = NULL;
Objetos_t objCell, objCellAlt;
// Vemos los objetos en el hexagono
infoCell = map.getHex( c.p );
if( infoCell != NULL && (infoCell->nivel + 2) > nivelMech ){
if( infoCell->objeto == 2 )
objCell.bosqueDenso++;
else if( infoCell->humo )
objCell.humo++;
else if( infoCell->objeto == 1 )
objCell.bosqueDisperso++;
}
// Vemos los objetos en el Hexagono alternativo
// En caso de existir
if( c.alt != NULL ){
infoCellAlt = map.getHex( *c.alt );
if( infoCellAlt != NULL && (infoCellAlt->nivel + 2) > nivelMech){
if( infoCellAlt->objeto == 2 )
objCellAlt.bosqueDenso++;
else if( infoCellAlt->humo )
objCellAlt.humo++;
else if( infoCellAlt->objeto == 1 )
objCellAlt.bosqueDisperso++;
}
}
// Comparamos a ver que Hexagono penaliza mas
if(objCell.bosqueDenso > 0 || objCellAlt.bosqueDenso > 0)
obj.bosqueDenso++;
else if(objCell.humo > 0 || objCellAlt.humo > 0)
obj.humo++;
else if(objCell.bosqueDisperso > 0 || objCellAlt.bosqueDisperso > 0)
obj.bosqueDisperso++;
}
示例5: CustomizeChildren
void FCameraFilmbackSettingsCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
// Retrieve structure's child properties
uint32 NumChildren;
StructPropertyHandle->GetNumChildren( NumChildren );
TMap<FName, TSharedPtr< IPropertyHandle > > PropertyHandles;
for( uint32 ChildIndex = 0; ChildIndex < NumChildren; ++ChildIndex )
{
TSharedRef<IPropertyHandle> ChildHandle = StructPropertyHandle->GetChildHandle( ChildIndex ).ToSharedRef();
const FName PropertyName = ChildHandle->GetProperty()->GetFName();
PropertyHandles.Add(PropertyName, ChildHandle);
}
// Retrieve special case properties
SensorWidthHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraFilmbackSettings, SensorWidth));
SensorHeightHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraFilmbackSettings, SensorHeight));
for( auto Iter(PropertyHandles.CreateConstIterator()); Iter; ++Iter )
{
IDetailPropertyRow& SettingsRow = ChildBuilder.AddChildProperty(Iter.Value().ToSharedRef());
}
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:23,代码来源:CameraFilmbackSettingsCustomization.cpp
示例6: VerifyFormatVersions
void VerifyFormatVersions(TMap<FString, uint16>& ReceivedFormatVersionMap)
{
for (auto Pair : ReceivedFormatVersionMap)
{
auto* Found = FormatVersionMap.Find(Pair.Key);
if (Found)
{
GFailedDueToShaderFormatVersion = true;
FCString::Snprintf(GErrorExceptionDescription, sizeof(GErrorExceptionDescription), TEXT("Mismatched shader version for format %s; did you forget to build ShaderCompilerWorker?"), *Pair.Key, *Found, Pair.Value);
checkf(Pair.Value == *Found, TEXT("Exiting due to mismatched shader version for format %s, version %d from ShaderCompilerWorker, received %d! Did you forget to build ShaderCompilerWorker?"), *Pair.Key, *Found, Pair.Value);
}
}
}
示例7:
bool FD3DGPUProfiler::FinishProfiling(TMap<int32, double>& OutEventIdToTimestampMap, ID3D11DeviceContext* Direct3DDeviceIMContext)
{
bool bSuccess = true;
check(CurrentGPUProfile);
// Get the disjoint timestamp query result.
CurrentGPUProfile->DisjointQuery.EndTracking();
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT DisjointQueryResult = CurrentGPUProfile->DisjointQuery.GetResult();
if(DisjointQueryResult.Disjoint)
{
bSuccess = false;
}
else
{
// Read back the timestamp query results.
for(int32 EventIndex = 0;EventIndex < CurrentGPUProfile->EventTimestampQueries.Num();++EventIndex)
{
TRefCountPtr<ID3D11Query> EventTimestampQuery = CurrentGPUProfile->EventTimestampQueries[EventIndex];
uint64 EventTimestamp;
const double StartTime = FPlatformTime::Seconds();
HRESULT QueryGetDataResult;
while(true)
{
QueryGetDataResult = Direct3DDeviceIMContext->GetData(EventTimestampQuery,&EventTimestamp,sizeof(EventTimestamp),0);
if(QueryGetDataResult == S_FALSE && (FPlatformTime::Seconds() - StartTime) < 0.5)
{
FPlatformProcess::Sleep(0.005f);
}
else
{
break;
}
}
if(QueryGetDataResult != S_OK)
{
bSuccess = false;
break;
}
else
{
OutEventIdToTimestampMap.Add(EventIndex,(double)EventTimestamp / (double)DisjointQueryResult.Frequency);
}
}
}
CurrentGPUProfile.Reset();
return bSuccess;
}
示例8: FindDataSample
bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){
//
// Find Data sample in the list of samples
//
TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));
if(!entry){
printf("Sample %s not found in the list of samples", g_sample.Data());
return false;
}
// Copy to output container
sampleinfis.SetOwner(kFALSE);
for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);
return true;
}
示例9: Accessor
void UJavascriptEditorLibrary::GetHeightmapDataToMemory(ULandscapeInfo* LandscapeInfo, int32 MinX, int32 MinY, int32 MaxX, int32 MaxY)
{
const int32 SizeX = (1 + MaxX - MinX);
const int32 SizeY = (1 + MaxY - MinY);
if (SizeX * SizeY * 2 == FArrayBufferAccessor::GetSize())
{
auto Buffer = (uint16*)FArrayBufferAccessor::GetData();
FHeightmapAccessor<false> Accessor(LandscapeInfo);
TMap<FIntPoint, uint16> Data;
Accessor.GetData(MinX, MinY, MaxX, MaxY, Data);
FMemory::Memzero(Buffer, SizeX * SizeY * 2);
for (auto it = Data.CreateConstIterator(); it; ++it)
{
const auto& Point = it.Key();
Buffer[Point.X + Point.Y * SizeX] = it.Value();
}
}
}
示例10: assert
ALWAYS_INLINE
typename std::enable_if<
std::is_base_of<BaseMap, TMap>::value, Object>::type
BaseMap::php_differenceByKey(const Variant& it) {
if (!it.isObject()) {
SystemLib::throwInvalidArgumentExceptionObject(
"Parameter it must be an instance of Iterable");
}
ObjectData* obj = it.getObjectData();
TMap* target = BaseMap::Clone<TMap>(this);
auto ret = Object::attach(target);
if (obj->isCollection()) {
if (isMapCollection(obj->collectionType())) {
auto map = static_cast<BaseMap*>(obj);
auto* eLimit = map->elmLimit();
for (auto* e = map->firstElm(); e != eLimit; e = nextElm(e, eLimit)) {
if (e->hasIntKey()) {
target->remove((int64_t)e->ikey);
} else {
assert(e->hasStrKey());
target->remove(e->skey);
}
}
return ret;
}
}
for (ArrayIter iter(obj); iter; ++iter) {
Variant k = iter.first();
if (k.isInteger()) {
target->remove(k.toInt64());
} else {
assert(k.isString());
target->remove(k.getStringData());
}
}
return ret;
}
示例11: TEXT
void FGlobalShaderMapId::AppendKeyString(FString& KeyString) const
{
TMap<const TCHAR*,FCachedUniformBufferDeclaration> ReferencedUniformBuffers;
for (int32 ShaderIndex = 0; ShaderIndex < ShaderTypeDependencies.Num(); ShaderIndex++)
{
KeyString += TEXT("_");
const FShaderTypeDependency& ShaderTypeDependency = ShaderTypeDependencies[ShaderIndex];
KeyString += ShaderTypeDependency.ShaderType->GetName();
// Add the type's source hash so that we can invalidate cached shaders when .usf changes are made
KeyString += ShaderTypeDependency.SourceHash.ToString();
// Add the serialization history to the key string so that we can detect changes to global shader serialization without a corresponding .usf change
ShaderTypeDependency.ShaderType->GetSerializationHistory().AppendKeyString(KeyString);
const TMap<const TCHAR*,FCachedUniformBufferDeclaration>& ReferencedUniformBufferStructsCache = ShaderTypeDependency.ShaderType->GetReferencedUniformBufferStructsCache();
// Gather referenced uniform buffers
for (TMap<const TCHAR*,FCachedUniformBufferDeclaration>::TConstIterator It(ReferencedUniformBufferStructsCache); It; ++It)
{
ReferencedUniformBuffers.Add(It.Key(), It.Value());
}
}
{
TArray<uint8> TempData;
FSerializationHistory SerializationHistory;
FMemoryWriter Ar(TempData, true);
FShaderSaveArchive SaveArchive(Ar, SerializationHistory);
// Save uniform buffer member info so we can detect when layout has changed
SerializeUniformBufferInfo(SaveArchive, ReferencedUniformBuffers);
SerializationHistory.AppendKeyString(KeyString);
}
}
示例12: GetWorld
// Called when the game starts or when spawned
void AGridV1::BeginPlay()
{
Super::BeginPlay();
int32 HalfX = GridSize.X / 2;
int32 HalfY = GridSize.Y / 2;
int32 HalfZ = GridSize.Z / 2;
FActorSpawnParameters param;
param.Owner = this;
for (int32 x = -HalfX; x < HalfX; x++)
{
for (int32 y = -HalfY; y < HalfY; y++)
{
for (int32 z = -HalfZ; z < HalfZ; z++)
{
ACellV1* cell = GetWorld()->SpawnActor<ACellV1>(FVector(x, y, z) * VoxelSize * CellSize, FRotator(), param);
cell->GridPosition = FInt3(x, y, z);
cell->Grid = this;
cell->FutureData = Async<TMap<FInt3, uint16>>(EAsyncExecution::ThreadPool, []()
{
TMap<FInt3, uint16> ret;
for (int32 i = 0; i < 32; i++)
for (int32 j = 0; j < 32; j++)
for (int32 k = 0; k < 32; k++)
ret.Add(FInt3(i, j, k), 1);
return ret;
});
cell->OngoingLoading = true;
cell->Mesh->SetMaterial(0, Material);
Data.Add(FInt3(x, y, z), cell);
}
}
}
}
示例13: UE_LOG
void FDirectoryWatchRequestLinux::UnwatchDirectoryTree(const FString & RootAbsolutePath)
{
UE_LOG(LogDirectoryWatcher, VeryVerbose, TEXT("Unwatching tree '%s'"), *RootAbsolutePath);
// remove the watch for the folder and all subfolders
// since it is expected that there will be a lot of them, just create a new TMap
TMap<FString, int32, FDefaultSetAllocator, FCaseSensitiveLookupKeyFuncs<int32>> NewPathsToWatchDescriptors;
for (auto MapIt = PathsToWatchDescriptors.CreateIterator(); MapIt; ++MapIt)
{
if (!MapIt->Key.StartsWith(RootAbsolutePath, ESearchCase::CaseSensitive))
{
NewPathsToWatchDescriptors.Add(MapIt->Key, MapIt->Value);
}
else
{
UE_LOG(LogDirectoryWatcher, VeryVerbose, TEXT("- Removing a watch %d for '%s'"), MapIt->Value, *MapIt->Key);
// delete the descriptor
int RetVal = inotify_rm_watch(FileDescriptor, MapIt->Value);
// why check for RootAbsolutePath? Because this function may be called when root path has been deleted, and inotify_rm_watch() will fail
// removing a watch on a deleted file... yay for API symmetry. Just "leak" the watch descriptor without the warning
if (RetVal == -1 || MapIt->Key != RootAbsolutePath)
{
int ErrNo = errno;
UE_LOG(LogDirectoryWatcher, Error, TEXT("inotify_rm_watch cannot remove descriptor %d for folder '%s' (errno = %d, %s)"),
MapIt->Value,
*MapIt->Key,
ErrNo,
ANSI_TO_TCHAR(strerror(ErrNo))
);
}
WatchDescriptorsToPaths.Remove(MapIt->Value);
}
}
PathsToWatchDescriptors = NewPathsToWatchDescriptors;
}
示例14: r3blandsim
void r3blandsim(
const Int_t n_neutrons,
const Int_t n_events,
const string neuland_geo_file,
const string input_file,
const string basename
){
// Output files
const TString out_file = "r3bsim." + basename + ".root";
const TString par_file = "r3bpar." + basename + ".root";
// Constant configuration
const TString target = "LiH";
const TString fMC = "TGeant3";
const TString fGene = "ascii";
const Bool_t fEventDisplay = kTRUE;
const Bool_t fUserPList = kTRUE;
const Bool_t fR3BMagnet = kTRUE;
const Double_t fMeasCurrent = 2500.;
// Geometry
TMap geometry;
geometry.Add(new TObjString("TARGET"), new TObjString("target_" + target + ".geo.root"));
geometry.Add(new TObjString("ALADIN"), new TObjString("aladin_v13a.geo.root"));
geometry.Add(new TObjString("CRYSTALBALL"), new TObjString("cal_v13a.geo.root"));
geometry.Add(new TObjString("DCH"), new TObjString("dch_v13a.geo.root"));
geometry.Add(new TObjString("SCINTNEULAND"), new TObjString(TString(neuland_geo_file)));
// Load the Main Simulation macro
const TString macro_r3ball = TString(getenv("VMCWORKDIR")) + TString("/macros/r3b/r3ball.C");
gROOT->LoadMacro(macro_r3ball.Data());
// Main Sim function call
r3ball( n_events, geometry, target, fEventDisplay, fMC, fGene, fUserPList, fR3BMagnet, fMeasCurrent, out_file, par_file, input_file);
}
示例15: GatherMods
float FGAEffectModifiersContainer::GatherMods(const FGameplayTagContainer& TagsIn, const TMap<FGAGameEffectHandle, TArray<FGAGameEffectModifier>>& Data)
{
//possible optimization when needed - create separate thread.
float ModifierVal = 0;
float Add = 0;
float Multiply = 1;
float Subtract = 0;
float Divide = 1;
float PercentageAdd = 0;
float PercentageSubtract = 0;
for (auto It = Data.CreateConstIterator(); It; ++It)
{
for (const FGAGameEffectModifier& Test : It->Value)
{
if (TagsIn.MatchesAll(Test.RequiredTags, false))
{
switch (Test.ModType)
{
case EGAAttributeMod::Add:
Add += Test.Value;
break;
case EGAAttributeMod::Multiply:
Multiply += Test.Value;
break;
case EGAAttributeMod::Subtract:
Subtract += Test.Value;
break;
case EGAAttributeMod::Divide:
Divide += Test.Value;
break;
case EGAAttributeMod::PercentageAdd:
PercentageAdd += Test.Value;
break;
case EGAAttributeMod::PercentageSubtract:
PercentageSubtract += Test.Value;
break;
default:
break;
}
}
}
}
ModifierVal = ((Add - Subtract) * Multiply) / Divide;
ModifierVal = ModifierVal + (ModifierVal * PercentageAdd);
ModifierVal = ModifierVal - (ModifierVal * PercentageSubtract);
SCOPE_CYCLE_COUNTER(STAT_GatherModifiers);
return ModifierVal;
}