本文整理汇总了C++中TMap::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TMap::Add方法的具体用法?C++ TMap::Add怎么用?C++ TMap::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMap
的用法示例。
在下文中一共展示了TMap::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetStartIndicesFromTimeRange
void FCombinedGraphDataSource::GetStartIndicesFromTimeRange( const float StartTimeMS, const float EndTimeMS, TMap<FGuid,uint32>& out_StartIndices ) const
{
for( auto It = GetSourcesIterator(); It; ++It )
{
const FGraphDataSourceRefConst& GraphDataSource = It.Value();
const FIntPoint IndicesForFrame = GraphDataSource->GetDataProvider()->GetClosestSamplesIndicesForTime( StartTimeMS, EndTimeMS );
const uint32 StartFrameIndex = IndicesForFrame.X;
const uint32 EndFrameIndex = IndicesForFrame.Y;
uint32 FrameIndex = 0;
float MaxFrameTime = 0.0f;
// Iterate through all frames and find the highest frame time.
for( uint32 InnerFrameIndex = StartFrameIndex; InnerFrameIndex < EndFrameIndex; ++InnerFrameIndex )
{
const float InnerFrameTime = GraphDataSource->GetDataProvider()->GetFrameTimeMS( InnerFrameIndex );
if( InnerFrameTime > MaxFrameTime )
{
MaxFrameTime = InnerFrameTime;
FrameIndex = InnerFrameIndex;
}
}
if( MaxFrameTime > 0.0f )
{
out_StartIndices.Add( GraphDataSource->GetSessionInstanceID(), FrameIndex );
}
}
}
示例2: FindChildGeometries_Helper
void SWidget::FindChildGeometries_Helper( const FGeometry& MyGeometry, const TSet< TSharedRef<SWidget> >& WidgetsToFind, TMap<TSharedRef<SWidget>, FArrangedWidget>& OutResult ) const
{
// Perform a breadth first search!
FArrangedChildren ArrangedChildren(EVisibility::Visible);
this->ArrangeChildren( MyGeometry, ArrangedChildren );
const int32 NumChildren = ArrangedChildren.Num();
// See if we found any of the widgets on this level.
for(int32 ChildIndex=0; ChildIndex < NumChildren; ++ChildIndex )
{
const FArrangedWidget& CurChild = ArrangedChildren[ ChildIndex ];
if ( WidgetsToFind.Contains(CurChild.Widget) )
{
// We found one of the widgets for which we need geometry!
OutResult.Add( CurChild.Widget, CurChild );
}
}
// If we have not found all the widgets that we were looking for, descend.
if ( OutResult.Num() != WidgetsToFind.Num() )
{
// Look for widgets among the children.
for( int32 ChildIndex=0; ChildIndex < NumChildren; ++ChildIndex )
{
const FArrangedWidget& CurChild = ArrangedChildren[ ChildIndex ];
CurChild.Widget->FindChildGeometries_Helper( CurChild.Geometry, WidgetsToFind, OutResult );
}
}
}
示例3: GatherStatsEventNode
/** Recursively generates a histogram of nodes and stores their timing in TimingResult. */
static void GatherStatsEventNode(FGPUProfilerEventNode* Node, int32 Depth, TMap<FString, FGPUProfilerEventNodeStats>& EventHistogram)
{
if (Node->NumDraws > 0 || Node->Children.Num() > 0)
{
Node->TimingResult = Node->GetTiming() * 1000.0f;
FGPUProfilerEventNodeStats* FoundHistogramBucket = EventHistogram.Find(Node->Name);
if (FoundHistogramBucket)
{
FoundHistogramBucket->NumDraws += Node->NumDraws;
FoundHistogramBucket->NumPrimitives += Node->NumPrimitives;
FoundHistogramBucket->NumVertices += Node->NumVertices;
FoundHistogramBucket->TimingResult += Node->TimingResult;
FoundHistogramBucket->NumEvents++;
}
else
{
FGPUProfilerEventNodeStats NewNodeStats;
NewNodeStats.NumDraws = Node->NumDraws;
NewNodeStats.NumPrimitives = Node->NumPrimitives;
NewNodeStats.NumVertices = Node->NumVertices;
NewNodeStats.TimingResult = Node->TimingResult;
NewNodeStats.NumEvents = 1;
EventHistogram.Add(Node->Name, NewNodeStats);
}
for (int32 ChildIndex = 0; ChildIndex < Node->Children.Num(); ChildIndex++)
{
// Traverse children
GatherStatsEventNode(Node->Children[ChildIndex], Depth + 1, EventHistogram);
}
}
}
示例4: AddStateWeight
void AddStateWeight(TMap<int32, float>& StateWeightMap, int32 StateIndex, float Weight)
{
if (!StateWeightMap.Find(StateIndex))
{
StateWeightMap.Add(StateIndex) = Weight;
}
}
示例5: InsertMetaDataPair
void FBaseParser::InsertMetaDataPair(TMap<FName, FString>& MetaData, const FString& InKey, const FString& InValue)
{
FString Key = InKey;
FString Value = InValue;
// trim extra white space and quotes
Key = Key.Trim().TrimTrailing();
Value = Value.Trim().TrimTrailing();
Value = Value.TrimQuotes();
// make sure the key is valid
if (InKey.Len() == 0)
{
FError::Throwf(TEXT("Invalid metadata"));
}
FName KeyName(*Key);
FString* ExistingValue = MetaData.Find(KeyName);
if (ExistingValue && Value != *ExistingValue)
{
FError::Throwf(TEXT("Metadata key '%s' first seen with value '%s' then '%s'"), *Key, **ExistingValue, *Value);
}
// finally we have enough to put it into our metadata
MetaData.Add(FName(*Key), *Value);
}
示例6: Bind
void Bind(UJavascriptDelegate* DelegateObject, Local<Function> function)
{
static FName NAME_Fire("Fire");
if (WeakObject.IsValid())
{
if (auto p = Cast<UMulticastDelegateProperty>(Property))
{
FScriptDelegate Delegate;
Delegate.BindUFunction(DelegateObject, NAME_Fire);
auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
Target->Add(Delegate);
}
else if (auto p = Cast<UDelegateProperty>(Property))
{
auto Target = p->GetPropertyValuePtr_InContainer(WeakObject.Get());
Target->BindUFunction(DelegateObject, NAME_Fire);
}
}
DelegateObject->JavascriptDelegate = this;
DelegateObject->AddToRoot();
DelegateObjects.Add(DelegateObject);
functions.Add( DelegateObject->UniqueId, UniquePersistent<Function>(isolate_, function) );
}
示例7: if
AGameplayDebuggerPlayerManager& FGameplayDebuggerModule::GetPlayerManager(UWorld* World)
{
const int32 PurgeInvalidWorldsSize = 5;
if (PlayerManagers.Num() > PurgeInvalidWorldsSize)
{
for (TMap<TWeakObjectPtr<UWorld>, TWeakObjectPtr<AGameplayDebuggerPlayerManager> >::TIterator It(PlayerManagers); It; ++It)
{
if (!It.Key().IsValid())
{
It.RemoveCurrent();
}
else if (!It.Value().IsValid())
{
It.RemoveCurrent();
}
}
}
TWeakObjectPtr<AGameplayDebuggerPlayerManager> Manager = PlayerManagers.FindRef(World);
AGameplayDebuggerPlayerManager* ManagerOb = Manager.Get();
if (ManagerOb == nullptr)
{
ManagerOb = World->SpawnActor<AGameplayDebuggerPlayerManager>();
PlayerManagers.Add(World, ManagerOb);
}
check(ManagerOb);
return *ManagerOb;
}
示例8: RHICreateVertexDeclaration
FVertexDeclarationRHIRef FOpenGLDynamicRHI::RHICreateVertexDeclaration(const FVertexDeclarationElementList& Elements)
{
// Construct a key from the elements.
FOpenGLVertexDeclarationKey Key(Elements);
// Check for a cached vertex declaration.
FVertexDeclarationRHIRef* VertexDeclarationRefPtr = GOpenGLVertexDeclarationCache.Find(Key);
if (VertexDeclarationRefPtr == NULL)
{
// Create and add to the cache if it doesn't exist.
VertexDeclarationRefPtr = &GOpenGLVertexDeclarationCache.Add(Key,new FOpenGLVertexDeclaration(Key.VertexElements));
check(VertexDeclarationRefPtr);
check(IsValidRef(*VertexDeclarationRefPtr));
FShaderCache::LogVertexDeclaration(Elements, *VertexDeclarationRefPtr);
}
// The cached declaration must match the input declaration!
check(VertexDeclarationRefPtr);
check(IsValidRef(*VertexDeclarationRefPtr));
FOpenGLVertexDeclaration* OpenGLVertexDeclaration = (FOpenGLVertexDeclaration*)VertexDeclarationRefPtr->GetReference();
checkSlow(OpenGLVertexDeclaration->VertexElements == Key.VertexElements);
return *VertexDeclarationRefPtr;
}
示例9: LoadModulesForPhase
void FModuleDescriptor::LoadModulesForPhase(ELoadingPhase::Type LoadingPhase, const TArray<FModuleDescriptor>& Modules, TMap<FName, EModuleLoadResult>& ModuleLoadErrors)
{
for(int Idx = 0; Idx < Modules.Num(); Idx++)
{
const FModuleDescriptor& Descriptor = Modules[Idx];
// Don't need to do anything if this module is already loaded
if( !FModuleManager::Get().IsModuleLoaded( Descriptor.Name ) )
{
if( LoadingPhase == Descriptor.LoadingPhase && Descriptor.IsLoadedInCurrentConfiguration() )
{
// @todo plugin: DLL search problems. Plugins that statically depend on other modules within this plugin may not be found? Need to test this.
// NOTE: Loading this module may cause other modules to become loaded, both in the engine or game, or other modules
// that are part of this project or plugin. That's totally fine.
EModuleLoadResult FailureReason;
const TSharedPtr<IModuleInterface>& ModuleInterface = FModuleManager::Get().LoadModuleWithFailureReason( Descriptor.Name, FailureReason );
if( ModuleInterface.IsValid() )
{
// Module loaded OK (or was already loaded.)
}
else
{
// The module failed to load. Note this in the ModuleLoadErrors list.
ModuleLoadErrors.Add(Descriptor.Name, FailureReason);
}
}
}
}
}
示例10: GetTrackKeyForTime
void UFaceFXMatineeControl::GetTrackKeyForTime(float InTime, TArray<TPair<int32, const FFaceFXTrackKey*>>& OutResult, TArray<FFaceFXSkelMeshComponentId>* OutNoTracks) const
{
//build a list of all keys for all skelmesh component ids
TMap<int32, TArray<const FFaceFXTrackKey*>> SkelMeshTracks;
TMap<int32, FFaceFXSkelMeshComponentId> SkelMeshIds;
for(const FFaceFXTrackKey& Key : Keys)
{
SkelMeshTracks.FindOrAdd(Key.SkelMeshComponentId.Index).Add(&Key);
if(OutNoTracks && !SkelMeshIds.Contains(Key.SkelMeshComponentId.Index))
{
SkelMeshIds.Add(Key.SkelMeshComponentId.Index, Key.SkelMeshComponentId);
}
}
//then generate the pair results for each skelmesh component
for(auto It = SkelMeshTracks.CreateConstIterator(); It; ++It)
{
const TArray<const FFaceFXTrackKey*>& SkelMeshKeys = It.Value();
const int32 IndexMax = SkelMeshKeys.Num()-1;
int32 Index = INDEX_NONE;
for(; Index < IndexMax && SkelMeshKeys[Index+1]->Time <= InTime; ++Index);
if(Index != INDEX_NONE)
{
OutResult.Add(TPairInitializer<int32, const FFaceFXTrackKey*>(Index, SkelMeshKeys[Index]));
}
else if(OutNoTracks)
{
OutNoTracks->Add(SkelMeshIds.FindChecked(It.Key()));
}
}
}
示例11: CustomizeChildren
void FCameraLensSettingsCustomization::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
MinFocalLengthHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraLensSettings, MinFocalLength));
MaxFocalLengthHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraLensSettings, MaxFocalLength));
MinFStopHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraLensSettings, MinFStop));
MaxFStopHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraLensSettings, MaxFStop));
MinFocusDistanceHandle = PropertyHandles.FindChecked(GET_MEMBER_NAME_CHECKED(FCameraLensSettings, MinimumFocusDistance));
for (auto Iter(PropertyHandles.CreateConstIterator()); Iter; ++Iter)
{
if (Iter.Value() == MinFocusDistanceHandle)
{
// skip showing these in the panel for now, as we don't really use them
continue;
}
IDetailPropertyRow& SettingsRow = ChildBuilder.AddChildProperty(Iter.Value().ToSharedRef());
}
}
示例12: RecursiveObjectCollection
void FContentComparisonHelper::RecursiveObjectCollection(UObject* InStartObject, int32 InCurrDepth, int32 InMaxDepth, TMap<UObject*,bool>& OutCollectedReferences)
{
// Serialize object with reference collector.
TArray<UObject*> LocalCollectedReferences;
FReferenceFinder ObjectReferenceCollector( LocalCollectedReferences, NULL, false, true, true, true );
ObjectReferenceCollector.FindReferences( InStartObject );
if (InCurrDepth < InMaxDepth)
{
InCurrDepth++;
for (int32 ObjRefIdx = 0; ObjRefIdx < LocalCollectedReferences.Num(); ObjRefIdx++)
{
UObject* InnerObject = LocalCollectedReferences[ObjRefIdx];
if ((InnerObject != NULL) &&
(InnerObject->IsA(UFunction::StaticClass()) == false) &&
(InnerObject->IsA(UPackage::StaticClass()) == false)
)
{
OutCollectedReferences.Add(InnerObject, true);
RecursiveObjectCollection(InnerObject, InCurrDepth, InMaxDepth, OutCollectedReferences);
}
}
InCurrDepth--;
}
}
示例13: Create
TSharedRef< ISlateRun > FHyperlinkDecorator::Create( const FTextRunParseResults& RunInfo, const FString& OriginalText, const TSharedRef< FString >& InOutModelText, const ISlateStyle* Style )
{
FString StyleName = TEXT("Hyperlink");
const FTextRange* const MetaDataStyleNameRange = RunInfo.MetaData.Find( TEXT("style") );
if ( MetaDataStyleNameRange != NULL )
{
const FString MetaDataStyleName = OriginalText.Mid(MetaDataStyleNameRange->BeginIndex, MetaDataStyleNameRange->EndIndex - MetaDataStyleNameRange->BeginIndex);
StyleName = *MetaDataStyleName;
}
FTextRange ModelRange;
ModelRange.BeginIndex = InOutModelText->Len();
*InOutModelText += OriginalText.Mid(RunInfo.ContentRange.BeginIndex, RunInfo.ContentRange.EndIndex - RunInfo.ContentRange.BeginIndex);
ModelRange.EndIndex = InOutModelText->Len();
if ( !Style->HasWidgetStyle<FHyperlinkStyle>( FName( *StyleName ) ) )
{
Style = &FCoreStyle::Get();
}
TMap<FString, FString> MetaData;
for(const TPair<FString, FTextRange>& Pair : RunInfo.MetaData)
{
MetaData.Add(Pair.Key, OriginalText.Mid( Pair.Value.BeginIndex, Pair.Value.EndIndex - Pair.Value.BeginIndex));
//MetaData[Pair.Key] = OriginalText.Mid( Pair.Value.BeginIndex, Pair.Value.EndIndex - Pair.Value.BeginIndex);
}
return FSlateHyperlinkRun::Create( InOutModelText, Style->GetWidgetStyle<FHyperlinkStyle>( FName( *StyleName ) ), MetaData, NavigateDelegate, ModelRange );
}
示例14: AddTypeDefinition
TSharedRef<FUnrealTypeDefinitionInfo> AddTypeDefinition(FUnrealSourceFile& SourceFile, UField* Field, int32 Line)
{
TSharedRef<FUnrealTypeDefinitionInfo> DefinitionInfo = MakeShareable(new FUnrealTypeDefinitionInfo(SourceFile, Line));
GTypeDefinitionInfoMap.Add(Field, DefinitionInfo);
return DefinitionInfo;
}
示例15: EnumerateEngineInstallations
void FDesktopPlatformWindows::EnumerateEngineInstallations(TMap<FString, FString> &OutInstallations)
{
// Enumerate the binary installations
EnumerateLauncherEngineInstallations(OutInstallations);
// Enumerate the per-user installations
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, InstallationsSubKey, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
{
// Get a list of all the directories
TArray<FString> UniqueDirectories;
OutInstallations.GenerateValueArray(UniqueDirectories);
// Enumerate all the installations
TArray<FString> InvalidKeys;
for (::DWORD Index = 0;; Index++)
{
TCHAR ValueName[256];
TCHAR ValueData[MAX_PATH];
::DWORD ValueType = 0;
::DWORD ValueNameLength = sizeof(ValueName) / sizeof(ValueName[0]);
::DWORD ValueDataSize = sizeof(ValueData);
LRESULT Result = RegEnumValue(hKey, Index, ValueName, &ValueNameLength, NULL, &ValueType, (BYTE*)&ValueData[0], &ValueDataSize);
if(Result == ERROR_SUCCESS)
{
int32 ValueDataLength = ValueDataSize / sizeof(TCHAR);
if(ValueDataLength > 0 && ValueData[ValueDataLength - 1] == 0) ValueDataLength--;
FString NormalizedInstalledDirectory(ValueDataLength, ValueData);
FPaths::NormalizeDirectoryName(NormalizedInstalledDirectory);
FPaths::CollapseRelativeDirectories(NormalizedInstalledDirectory);
if(IsValidRootDirectory(NormalizedInstalledDirectory) && !UniqueDirectories.Contains(NormalizedInstalledDirectory))
{
OutInstallations.Add(ValueName, NormalizedInstalledDirectory);
UniqueDirectories.Add(NormalizedInstalledDirectory);
}
else
{
InvalidKeys.Add(ValueName);
}
}
else if(Result == ERROR_NO_MORE_ITEMS)
{
break;
}
}
// Remove all the keys which weren't valid
for(const FString InvalidKey: InvalidKeys)
{
RegDeleteValue(hKey, *InvalidKey);
}
RegCloseKey(hKey);
}
}