本文整理汇总了C++中TSet::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ TSet::Contains方法的具体用法?C++ TSet::Contains怎么用?C++ TSet::Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSet
的用法示例。
在下文中一共展示了TSet::Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateDuplicatedLayerName
FText STileLayerList::GenerateDuplicatedLayerName(const FString& InputNameRaw, UPaperTileMap* TileMap)
{
// Create a set of existing names
TSet<FString> ExistingNames;
for (UPaperTileLayer* ExistingLayer : TileMap->TileLayers)
{
ExistingNames.Add(ExistingLayer->LayerName.ToString());
}
FString BaseName = InputNameRaw;
int32 TestIndex = 0;
bool bAddNumber = false;
// See if this is the result of a previous duplication operation, and change the desired name accordingly
int32 SpaceIndex;
if (InputNameRaw.FindLastChar(' ', /*out*/ SpaceIndex))
{
FString PossibleDuplicationSuffix = InputNameRaw.Mid(SpaceIndex + 1);
if (PossibleDuplicationSuffix == TEXT("copy"))
{
bAddNumber = true;
BaseName = InputNameRaw.Left(SpaceIndex);
TestIndex = 2;
}
else
{
int32 ExistingIndex = FCString::Atoi(*PossibleDuplicationSuffix);
const FString TestSuffix = FString::Printf(TEXT(" copy %d"), ExistingIndex);
if (InputNameRaw.EndsWith(TestSuffix))
{
bAddNumber = true;
BaseName = InputNameRaw.Left(InputNameRaw.Len() - TestSuffix.Len());
TestIndex = ExistingIndex + 1;
}
}
}
// Find a good name
FString TestLayerName = BaseName + TEXT(" copy");
if (bAddNumber || ExistingNames.Contains(TestLayerName))
{
do
{
TestLayerName = FString::Printf(TEXT("%s copy %d"), *BaseName, TestIndex++);
} while (ExistingNames.Contains(TestLayerName));
}
return FText::FromString(TestLayerName);
}
示例2: Convert
void FBlueprintNativeCodeGenModule::Convert(UPackage* Package, ESavePackageResult CookResult, const TCHAR* PlatformName)
{
// Find the struct/enum to convert:
UStruct* Struct = nullptr;
UEnum* Enum = nullptr;
GetFieldFormPackage(Package, Struct, Enum);
// First we gather information about bound functions.
UClass* AsClass = Cast<UClass>(Struct);
UBlueprint* BP = AsClass ? Cast<UBlueprint>(AsClass->ClassGeneratedBy) : nullptr;
if (BP)
{
CollectBoundFunctions(BP);
}
if (CookResult != ESavePackageResult::ReplaceCompletely && CookResult != ESavePackageResult::GenerateStub)
{
// nothing to convert
return;
}
if (Struct == nullptr && Enum == nullptr)
{
ensure(false);
return;
}
if (CookResult == ESavePackageResult::GenerateStub)
{
if (ensure(BP))
{
ensure(!ToGenerate.Contains(BP));
AllPotentialStubs.Add(BP);
}
}
else
{
check(CookResult == ESavePackageResult::ReplaceCompletely);
if (AsClass)
{
if (ensure(BP))
{
ensure(!AllPotentialStubs.Contains(BP));
ToGenerate.Add(BP);
}
}
else
{
UField* ForConversion = Struct ? (UField*)Struct : (UField*)Enum;
GenerateSingleAsset(ForConversion, PlatformName);
}
}
}
示例3: 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 );
}
}
}
示例4: GetActorsToIgnore
static void GetActorsToIgnore( AActor* Actor, TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore )
{
if( !ActorsToIgnore.Contains( Actor ) )
{
ActorsToIgnore.Add( Actor );
// We cannot snap to any attached children or actors in the same group as moving this actor will also move the children as we are snapping to them,
// causing a cascading effect and unexpected results
TArray<USceneComponent*>& AttachedChildren = Actor->GetRootComponent()->AttachChildren;
for( int32 ChildIndex = 0; ChildIndex < AttachedChildren.Num(); ++ChildIndex )
{
USceneComponent* Child = AttachedChildren[ChildIndex];
if( Child && Child->GetOwner() )
{
ActorsToIgnore.Add( Child->GetOwner() );
}
}
AGroupActor* ParentGroup = AGroupActor::GetRootForActor(Actor, true, true);
if( ParentGroup )
{
TArray<AActor*> GroupActors;
ParentGroup->GetGroupActors(GroupActors, true);
for( int32 GroupActorIndex = 0; GroupActorIndex < GroupActors.Num(); ++GroupActorIndex )
{
ActorsToIgnore.Add( GroupActors[GroupActorIndex] );
}
}
}
}
示例5: IsValidXName
bool FName::IsValidXName( FString InvalidChars/*=INVALID_NAME_CHARACTERS*/, FText* Reason/*=NULL*/ ) const
{
FString Name = ToString();
// See if the name contains invalid characters.
TCHAR CharString[] = { '\0', '\0' };
FString MatchedInvalidChars;
TSet<TCHAR> AlreadyMatchedInvalidChars;
for( int32 x = 0; x < InvalidChars.Len() ; ++x )
{
TCHAR CharToTest = InvalidChars[x];
CharString[0] = CharToTest;
if( !AlreadyMatchedInvalidChars.Contains( CharToTest ) && Name.Contains( CharString ) )
{
MatchedInvalidChars += CharString;
AlreadyMatchedInvalidChars.Add( CharToTest );
}
}
if ( MatchedInvalidChars.Len() )
{
if ( Reason )
{
FFormatNamedArguments Args;
Args.Add(TEXT("IllegalNameCharacters"), FText::FromString(MatchedInvalidChars));
*Reason = FText::Format( NSLOCTEXT("Core", "NameContainsInvalidCharacters", "Name may not contain the following characters: {IllegalNameCharacters}"), Args );
}
return false;
}
return true;
}
示例6: GenerateStubs
void FBlueprintNativeCodeGenModule::GenerateStubs()
{
TSet<TAssetPtr<UBlueprint>> AlreadyGenerated;
while (AlreadyGenerated.Num() < StubsRequiredByGeneratedCode.Num())
{
const int32 OldGeneratedNum = AlreadyGenerated.Num();
for (TAssetPtr<UBlueprint>& BPPtr : StubsRequiredByGeneratedCode)
{
bool bAlreadyGenerated = false;
AlreadyGenerated.Add(BPPtr, &bAlreadyGenerated);
if (bAlreadyGenerated)
{
continue;
}
ensureMsgf(AllPotentialStubs.Contains(BPPtr), TEXT("A required blueprint doesn't generate stub: %s"), *BPPtr.ToString());
for (auto& PlatformName : TargetPlatformNames)
{
GenerateSingleStub(BPPtr.LoadSynchronous(), *PlatformName);
}
}
if (!ensure(OldGeneratedNum != AlreadyGenerated.Num()))
{
break;
}
}
UE_LOG(LogBlueprintCodeGen, Log, TEXT("GenerateStubs - all unconverted bp: %d, generated wrapers: %d"), AllPotentialStubs.Num(), StubsRequiredByGeneratedCode.Num());
}
示例7: PropagateTransformPropertyChange
void FComponentEditorUtils::PropagateTransformPropertyChange(
class USceneComponent* InSceneComponentTemplate,
const FTransformData& OldDefaultTransform,
const FTransformData& NewDefaultTransform,
TSet<class USceneComponent*>& UpdatedComponents)
{
check(InSceneComponentTemplate != nullptr);
TArray<UObject*> ArchetypeInstances;
FComponentEditorUtils::GetArchetypeInstances(InSceneComponentTemplate, ArchetypeInstances);
for(int32 InstanceIndex = 0; InstanceIndex < ArchetypeInstances.Num(); ++InstanceIndex)
{
USceneComponent* InstancedSceneComponent = FComponentEditorUtils::GetSceneComponent(ArchetypeInstances[InstanceIndex], InSceneComponentTemplate);
if(InstancedSceneComponent != nullptr && !UpdatedComponents.Contains(InstancedSceneComponent))
{
static const UProperty* RelativeLocationProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeLocation" );
if(RelativeLocationProperty != nullptr)
{
PropagateTransformPropertyChange(InstancedSceneComponent, RelativeLocationProperty, OldDefaultTransform.Trans, NewDefaultTransform.Trans, UpdatedComponents);
}
static const UProperty* RelativeRotationProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeRotation" );
if(RelativeRotationProperty != nullptr)
{
PropagateTransformPropertyChange(InstancedSceneComponent, RelativeRotationProperty, OldDefaultTransform.Rot, NewDefaultTransform.Rot, UpdatedComponents);
}
static const UProperty* RelativeScale3DProperty = FindFieldChecked<UProperty>( USceneComponent::StaticClass(), "RelativeScale3D" );
if(RelativeScale3DProperty != nullptr)
{
PropagateTransformPropertyChange(InstancedSceneComponent, RelativeScale3DProperty, OldDefaultTransform.Scale, NewDefaultTransform.Scale, UpdatedComponents);
}
}
}
}
示例8: NewPath
TArray<FPropertySoftPath> DiffUtils::GetVisiblePropertiesInOrderDeclared(const UObject* ForObj, const TArray<FName>& Scope /*= TArray<FName>()*/)
{
TArray<FPropertySoftPath> Ret;
if (ForObj)
{
const UClass* Class = ForObj->GetClass();
TSet<FString> HiddenCategories = FEditorCategoryUtils::GetHiddenCategories(Class);
for (TFieldIterator<UProperty> PropertyIt(Class); PropertyIt; ++PropertyIt)
{
FName CategoryName = FObjectEditorUtils::GetCategoryFName(*PropertyIt);
if (!HiddenCategories.Contains(CategoryName.ToString()))
{
if (PropertyIt->PropertyFlags&CPF_Edit)
{
TArray<FName> NewPath(Scope);
NewPath.Push(PropertyIt->GetFName());
if (const UObjectProperty* ObjectProperty = Cast<UObjectProperty>(*PropertyIt))
{
const UObject* const* BaseObject = reinterpret_cast<const UObject* const*>( ObjectProperty->ContainerPtrToValuePtr<void>(ForObj) );
if (BaseObject && *BaseObject)
{
Ret.Append( GetVisiblePropertiesInOrderDeclared(*BaseObject, NewPath) );
}
}
else
{
Ret.Push(NewPath);
}
}
}
}
}
return Ret;
}
示例9: OnBeginDrag
void FMoveKeys::OnBeginDrag(const FVector2D& LocalMousePos, TSharedPtr<FTrackNode> SequencerNode)
{
check( SelectedKeys.Num() > 0 )
// Begin an editor transaction and mark the section as transactional so it's state will be saved
GEditor->BeginTransaction( NSLOCTEXT("Sequencer", "MoveKeysTransaction", "Move Keys") );
TSet<UMovieSceneSection*> ModifiedSections;
for( FSelectedKey SelectedKey : SelectedKeys )
{
UMovieSceneSection* OwningSection = SelectedKey.Section;
// Only modify sections once
if( !ModifiedSections.Contains( OwningSection ) )
{
OwningSection->SetFlags( RF_Transactional );
// Save the current state of the section
OwningSection->Modify();
// Section has been modified
ModifiedSections.Add( OwningSection );
}
}
}
示例10: ParseFramesFromSpriteArray
static bool ParseFramesFromSpriteArray(const TArray<TSharedPtr<FJsonValue>>& ArrayBlock, TArray<FSpriteFrame>& OutSpriteFrames, TSet<FName>& FrameNames)
{
GWarn->BeginSlowTask(NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frame"), true, true);
bool bLoadedSuccessfully = true;
// Parse all of the frames
for (int32 FrameCount = 0; FrameCount < ArrayBlock.Num(); ++FrameCount)
{
GWarn->StatusUpdate(FrameCount, ArrayBlock.Num(), NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frames"));
bool bReadFrameSuccessfully = true;
FSpriteFrame Frame;
const TSharedPtr<FJsonValue>& FrameDataAsValue = ArrayBlock[FrameCount];
if (FrameDataAsValue->Type == EJson::Object)
{
TSharedPtr<FJsonObject> FrameData;
FrameData = FrameDataAsValue->AsObject();
FString FrameFilename = FPaperJSONHelpers::ReadString(FrameData, TEXT("filename"), TEXT(""));
if (!FrameFilename.IsEmpty())
{
Frame.FrameName = FName(*FrameFilename); // case insensitive
if (FrameNames.Contains(Frame.FrameName))
{
bReadFrameSuccessfully = false;
}
else
{
FrameNames.Add(Frame.FrameName);
}
bReadFrameSuccessfully = bReadFrameSuccessfully && ParseFrame(FrameData, /*out*/Frame);
}
else
{
bReadFrameSuccessfully = false;
}
}
else
{
bReadFrameSuccessfully = false;
}
if (bReadFrameSuccessfully)
{
OutSpriteFrames.Add(Frame);
}
else
{
UE_LOG(LogPaperSpriteSheetImporter, Warning, TEXT("Frame %s is in an unexpected format"), *Frame.FrameName.ToString());
bLoadedSuccessfully = false;
}
}
GWarn->EndSlowTask();
return bLoadedSuccessfully;
}
示例11: PostProcessPastedNodes
// Reconcile other pin links:
// - Links between nodes within the copied set are fine
// - Links to nodes that were not copied need to be fixed up if the copy-paste was in the same graph or broken completely
// Call PostPasteNode on each node
void FEdGraphUtilities::PostProcessPastedNodes(TSet<UEdGraphNode*>& SpawnedNodes)
{
// Run thru and fix up the node's pin links; they may point to invalid pins if the paste was to another graph
for (TSet<UEdGraphNode*>::TIterator It(SpawnedNodes); It; ++It)
{
UEdGraphNode* Node = *It;
UEdGraph* CurrentGraph = Node->GetGraph();
for (int32 PinIndex = 0; PinIndex < Node->Pins.Num(); ++PinIndex)
{
UEdGraphPin* ThisPin = Node->Pins[PinIndex];
for (int32 LinkIndex = 0; LinkIndex < ThisPin->LinkedTo.Num(); )
{
UEdGraphPin* OtherPin = ThisPin->LinkedTo[LinkIndex];
if (OtherPin == NULL)
{
// Totally bogus link
ThisPin->LinkedTo.RemoveAtSwap(LinkIndex);
}
else if (!SpawnedNodes.Contains(OtherPin->GetOwningNode()))
{
// It's a link across the selection set, so it should be broken
OtherPin->LinkedTo.RemoveSwap(ThisPin);
ThisPin->LinkedTo.RemoveAtSwap(LinkIndex);
}
else if (!OtherPin->LinkedTo.Contains(ThisPin))
{
// The link needs to be reciprocal
check(OtherPin->GetOwningNode()->GetGraph() == CurrentGraph);
OtherPin->LinkedTo.Add(ThisPin);
++LinkIndex;
}
else
{
// Everything seems fine but sanity check the graph
check(OtherPin->GetOwningNode()->GetGraph() == CurrentGraph);
++LinkIndex;
}
}
}
}
// Give every node a chance to deep copy associated resources, etc...
for (TSet<UEdGraphNode*>::TIterator It(SpawnedNodes); It; ++It)
{
UEdGraphNode* Node = *It;
Node->PostPasteNode();
Node->ReconstructNode();
// Ensure we have RF_Transactional set on all pasted nodes, as its not copied in the T3D format
Node->SetFlags(RF_Transactional);
}
}
示例12: ScaleCurve
void FRichCurve::ScaleCurve(float ScaleOrigin, float ScaleFactor, TSet<FKeyHandle>& KeyHandles)
{
for (auto It = KeyHandlesToIndices.CreateIterator(); It; ++It)
{
const FKeyHandle& KeyHandle = It.Key();
if (KeyHandles.Num() != 0 && KeyHandles.Contains(KeyHandle))
{
SetKeyTime(KeyHandle, (GetKeyTime(KeyHandle) - ScaleOrigin) * ScaleFactor + ScaleOrigin);
}
}
}
示例13: ShiftCurve
void FRichCurve::ShiftCurve(float DeltaTime, TSet<FKeyHandle>& KeyHandles)
{
for (auto It = KeyHandlesToIndices.CreateIterator(); It; ++It)
{
const FKeyHandle& KeyHandle = It.Key();
if (KeyHandles.Num() != 0 && KeyHandles.Contains(KeyHandle))
{
SetKeyTime(KeyHandle, GetKeyTime(KeyHandle)+DeltaTime);
}
}
}
示例14: ParseFramesFromSpriteHash
static bool ParseFramesFromSpriteHash(TSharedPtr<FJsonObject> ObjectBlock, TArray<FSpriteFrame>& OutSpriteFrames, TSet<FName>& FrameNames)
{
GWarn->BeginSlowTask(NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frame"), true, true);
bool bLoadedSuccessfully = true;
// Parse all of the frames
int32 FrameCount = 0;
for (auto FrameIt = ObjectBlock->Values.CreateIterator(); FrameIt; ++FrameIt)
{
GWarn->StatusUpdate(FrameCount, ObjectBlock->Values.Num(), NSLOCTEXT("Paper2D", "PaperJsonImporterFactory_ParsingSprites", "Parsing Sprite Frames"));
bool bReadFrameSuccessfully = true;
FSpriteFrame Frame;
Frame.FrameName = *FrameIt.Key();
if (FrameNames.Contains(Frame.FrameName))
{
bReadFrameSuccessfully = false;
}
else
{
FrameNames.Add(Frame.FrameName);
}
TSharedPtr<FJsonValue> FrameDataAsValue = FrameIt.Value();
TSharedPtr<FJsonObject> FrameData;
if (FrameDataAsValue->Type == EJson::Object)
{
FrameData = FrameDataAsValue->AsObject();
bReadFrameSuccessfully = bReadFrameSuccessfully && ParseFrame(FrameData, /*out*/Frame);
}
else
{
bReadFrameSuccessfully = false;
}
if (bReadFrameSuccessfully)
{
OutSpriteFrames.Add(Frame);
}
else
{
UE_LOG(LogPaperSpriteSheetImporter, Warning, TEXT("Frame %s is in an unexpected format"), *Frame.FrameName.ToString());
bLoadedSuccessfully = false;
}
FrameCount++;
}
GWarn->EndSlowTask();
return bLoadedSuccessfully;
}
示例15: RemoveOrphanedNodes
void UEnvironmentQueryGraph::RemoveOrphanedNodes()
{
UEnvQuery* QueryAsset = CastChecked<UEnvQuery>(GetOuter());
// Obtain a list of all nodes that should be in the asset
TSet<UObject*> AllNodes;
for (int32 Index = 0; Index < Nodes.Num(); ++Index)
{
UEnvironmentQueryGraphNode_Option* OptionNode = Cast<UEnvironmentQueryGraphNode_Option>(Nodes[Index]);
if (OptionNode)
{
UEnvQueryOption* OptionInstance = Cast<UEnvQueryOption>(OptionNode->NodeInstance);
if (OptionInstance)
{
AllNodes.Add(OptionInstance);
if (OptionInstance->Generator)
{
AllNodes.Add(OptionInstance->Generator);
}
}
for (int32 SubIdx = 0; SubIdx < OptionNode->Tests.Num(); SubIdx++)
{
if (OptionNode->Tests[SubIdx] && OptionNode->Tests[SubIdx]->NodeInstance)
{
AllNodes.Add(OptionNode->Tests[SubIdx]->NodeInstance);
}
}
}
}
// Obtain a list of all nodes actually in the asset and discard unused nodes
TArray<UObject*> AllInners;
const bool bIncludeNestedObjects = false;
GetObjectsWithOuter(QueryAsset, AllInners, bIncludeNestedObjects);
for (auto InnerIt = AllInners.CreateConstIterator(); InnerIt; ++InnerIt)
{
UObject* Node = *InnerIt;
const bool bEQSNode =
Node->IsA(UEnvQueryGenerator::StaticClass()) ||
Node->IsA(UEnvQueryTest::StaticClass()) ||
Node->IsA(UEnvQueryOption::StaticClass());
if (bEQSNode && !AllNodes.Contains(Node))
{
Node->SetFlags(RF_Transient);
Node->Rename(NULL, GetTransientPackage(), REN_DontCreateRedirectors | REN_NonTransactional | REN_ForceNoResetLoaders);
}
}
}