本文整理汇总了C++中TSet::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TSet::Empty方法的具体用法?C++ TSet::Empty怎么用?C++ TSet::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSet
的用法示例。
在下文中一共展示了TSet::Empty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PurgeAllDelegates
void PurgeAllDelegates()
{
for (auto d : Delegates)
{
delete d;
}
Delegates.Empty();
}
示例2: TEXT
uint32 FArchiveObjectCrc32::Crc32(UObject* Object, uint32 CRC)
{
#ifdef DEBUG_ARCHIVE_OBJECT_CRC32
const double StartTime = FPlatformTime::Seconds();
UE_LOG(LogArchiveObjectCrc32, Log, TEXT("### Calculating CRC for object: %s with outer: %s"), *Object->GetName(), Object->GetOuter() ? *Object->GetOuter()->GetName() : TEXT("NULL"));
#endif
RootObject = Object;
if (Object)
{
TSet<UObject*> SerializedObjects;
// Start with the given object
ObjectsToSerialize.Enqueue(Object);
// Continue until we no longer have any objects to serialized
while (ObjectsToSerialize.Dequeue(Object))
{
bool bAlreadyProcessed = false;
SerializedObjects.Add(Object, &bAlreadyProcessed);
// If we haven't already serialized this object
if (!bAlreadyProcessed)
{
#ifdef DEBUG_ARCHIVE_OBJECT_CRC32
UE_LOG(LogArchiveObjectCrc32, Log, TEXT("- Serializing object: %s with outer: %s"), *Object->GetName(), Object->GetOuter() ? *Object->GetOuter()->GetName() : TEXT("NULL"));
#endif
// Serialize it
ObjectBeingSerialized = Object;
if (!CustomSerialize(Object))
{
Object->Serialize(*this);
}
ObjectBeingSerialized = NULL;
// Calculate the CRC, compounding it with the checksum calculated from the previous object
CRC = FCrc::MemCrc32(SerializedObjectData.GetData(), SerializedObjectData.Num(), CRC);
#ifdef DEBUG_ARCHIVE_OBJECT_CRC32
UE_LOG(LogArchiveObjectCrc32, Log, TEXT("=> object: '%s', total size: %d bytes, checksum: 0x%08x"), *GetPathNameSafe(Object), SerializedObjectData.Num(), CRC);
#endif
// Cleanup
MemoryWriter.Seek(0L);
SerializedObjectData.Empty();
}
}
// Cleanup
SerializedObjects.Empty();
RootObject = NULL;
}
#ifdef DEBUG_ARCHIVE_OBJECT_CRC32
UE_LOG(LogArchiveObjectCrc32, Log, TEXT("### Finished (%.02f ms), final checksum: 0x%08x"), (FPlatformTime::Seconds() - StartTime) * 1000.0f, CRC);
#endif
return CRC;
}
示例3: world
/*Function which retrieves an arranged list of assets with the same nature (coresponding tags: Item, Stackable, ItemType)
which are placed on top of one another in the world (eg: a stack of plates)
The list is used for picking up multiple items at once in the GrabWithTwoHands() method.
@param AActor* ContainedItem --> Actor contained within the stack needed
*/
TSet<AActor*> AMyCharacter::GetStack(AActor* ContainedItem)
{
//Create an empty array to be populated with proper values
TSet<AActor*> StackList;
StackList.Empty();
//Make sure that the function parameter is logicaly valid and if not return an empty stack and exit the function call
if (!ContainedItem->ActorHasTag(FName(TEXT("Stackable"))))
{
return StackList;
}
/*Loop through the list of stackable items created in BeginPlay() and check for matching tags, as well as world positioning,
and populate the array with elements which are found to have the center on the same Z axis as the recieved parameter (+/- a small offset)
*/
for (const auto Iterator : AllStackableItems)
{
if (Iterator->Tags == ContainedItem->Tags)
{
if ((ContainedItem->GetActorLocation().X - 2 < Iterator->GetActorLocation().X) &&
(Iterator->GetActorLocation().X < ContainedItem->GetActorLocation().X + 2) &&
(ContainedItem->GetActorLocation().Y - 2 < Iterator->GetActorLocation().Y) &&
(Iterator->GetActorLocation().Y< ContainedItem->GetActorLocation().Y + 2))
{
StackList.Add(Iterator);
}
}
}
//Bubble sort algorithm
bool swapped = true;
int j = 0;
AActor* tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < StackList.Num() - j; i++) {
if (StackList[FSetElementId::FromInteger(i)]->GetActorLocation().Z > StackList[FSetElementId::FromInteger(i + 1)]->GetActorLocation().Z)
{
tmp = StackList[FSetElementId::FromInteger(i)];
StackList[FSetElementId::FromInteger(i)] = StackList[FSetElementId::FromInteger(i + 1)];
StackList[FSetElementId::FromInteger(i + 1)] = tmp;
swapped = true;
}
}
}
return StackList;
}
示例4: DissociateImportsAndForcedExports
/**
* Dissociates all linker import and forced export object references. This currently needs to
* happen as the referred objects might be destroyed at any time.
*/
void DissociateImportsAndForcedExports()
{
if( GImportCount && GObjLoadersWithNewImports.Num())
{
for (TSet< ULinkerLoad*>::TIterator It(GObjLoadersWithNewImports); It; ++It)
{
ULinkerLoad* Linker = *It;
for( int32 ImportIndex=0; ImportIndex<Linker->ImportMap.Num(); ImportIndex++ )
{
FObjectImport& Import = Linker->ImportMap[ImportIndex];
if( Import.XObject && !Import.XObject->HasAnyFlags(RF_Native) )
{
Import.XObject = NULL;
}
Import.SourceLinker = NULL;
// when the SourceLinker is reset, the SourceIndex must also be reset, or recreating
// an import that points to a redirector will fail to find the redirector
Import.SourceIndex = INDEX_NONE;
}
}
}
GImportCount = 0;
GObjLoadersWithNewImports.Empty();
if( GForcedExportCount )
{
for (TMap<UPackage*, ULinkerLoad*>::TIterator It(GObjLoaders); It; ++It)
{
ULinkerLoad* Linker = It.Value();
//@todo optimization: only dissociate exports for loaders that had forced exports created
//@todo optimization: since the last time this function was called.
for( int32 ExportIndex=0; ExportIndex<Linker->ExportMap.Num(); ExportIndex++ )
{
FObjectExport& Export = Linker->ExportMap[ExportIndex];
if( Export.Object && Export.bForcedExport )
{
Export.Object->SetLinker( NULL, INDEX_NONE );
Export.Object = NULL;
}
}
}
}
GForcedExportCount = 0;
}
示例5: UpdateAvailableBlueprintClasses
void FGraphNodeClassHelper::UpdateAvailableBlueprintClasses()
{
if (FModuleManager::Get().IsModuleLoaded(TEXT("AssetRegistry")))
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
const bool bSearchSubClasses = true;
TArray<FName> ClassNames;
TSet<FName> DerivedClassNames;
for (TMap<UClass*, int32>::TIterator It(BlueprintClassCount); It; ++It)
{
ClassNames.Reset();
ClassNames.Add(It.Key()->GetFName());
DerivedClassNames.Empty(DerivedClassNames.Num());
AssetRegistryModule.Get().GetDerivedClassNames(ClassNames, TSet<FName>(), DerivedClassNames);
int32& Count = It.Value();
Count = DerivedClassNames.Num();
}
}
}
示例6: OnPinMouseDown
FReply SGraphPin::OnPinMouseDown( const FGeometry& SenderGeometry, const FPointerEvent& MouseEvent )
{
bIsMovingLinks = false;
if (MouseEvent.GetEffectingButton() == EKeys::LeftMouseButton)
{
if (!GraphPinObj->bNotConnectable && IsEditable.Get())
{
if (MouseEvent.IsAltDown())
{
// Alt-Left clicking will break all existing connections to a pin
const UEdGraphSchema* Schema = GraphPinObj->GetSchema();
Schema->BreakPinLinks(*GraphPinObj, true);
return FReply::Handled();
}
auto OwnerNodePinned = OwnerNodePtr.Pin();
if (MouseEvent.IsControlDown() && (GraphPinObj->LinkedTo.Num() > 0))
{
// Get a reference to the owning panel widget
check(OwnerNodePinned.IsValid());
TSharedPtr<SGraphPanel> OwnerPanelPtr = OwnerNodePinned->GetOwnerPanel();
check(OwnerPanelPtr.IsValid());
// Obtain the set of all pins within the panel
TSet<TSharedRef<SWidget> > AllPins;
OwnerPanelPtr->GetAllPins(AllPins);
// Construct a UEdGraphPin->SGraphPin mapping for the full pin set
TMap< UEdGraphPin*, TSharedRef<SGraphPin> > PinToPinWidgetMap;
for( TSet< TSharedRef<SWidget> >::TIterator ConnectorIt(AllPins); ConnectorIt; ++ConnectorIt )
{
const TSharedRef<SWidget>& SomePinWidget = *ConnectorIt;
const SGraphPin& PinWidget = static_cast<const SGraphPin&>(SomePinWidget.Get());
PinToPinWidgetMap.Add(PinWidget.GetPinObj(), StaticCastSharedRef<SGraphPin>(SomePinWidget));
}
// Define a local struct to temporarily store lookup information for pins that we are currently linked to
struct LinkedToPinInfo
{
// Pin name string
FString PinName;
// A weak reference to the node object that owns the pin
TWeakObjectPtr<UEdGraphNode> OwnerNodePtr;
};
// Build a lookup table containing information about the set of pins that we're currently linked to
TArray<LinkedToPinInfo> LinkedToPinInfoArray;
for( TArray<UEdGraphPin*>::TIterator LinkArrayIter(GetPinObj()->LinkedTo); LinkArrayIter; ++LinkArrayIter )
{
if (auto PinWidget = PinToPinWidgetMap.Find(*LinkArrayIter))
{
check((*PinWidget)->OwnerNodePtr.IsValid());
LinkedToPinInfo PinInfo;
PinInfo.PinName = (*PinWidget)->GetPinObj()->PinName;
PinInfo.OwnerNodePtr = (*PinWidget)->OwnerNodePtr.Pin()->GetNodeObj();
LinkedToPinInfoArray.Add(PinInfo);
}
}
// Control-Left clicking will break all existing connections to a pin
// Note that for some nodes, this can cause reconstruction. In that case, pins we had previously linked to may now be destroyed.
const UEdGraphSchema* Schema = GraphPinObj->GetSchema();
Schema->BreakPinLinks(*GraphPinObj, true);
// Check to see if the panel has been invalidated by a graph change notification
if (!OwnerPanelPtr->Contains(OwnerNodePinned->GetNodeObj()))
{
// Force the panel to update. This will cause node & pin widgets to be reinstanced to match any reconstructed node/pin object references.
OwnerPanelPtr->Update();
// Obtain the full set of pins again after the update
AllPins.Empty(AllPins.Num());
OwnerPanelPtr->GetAllPins(AllPins);
// Rebuild the UEdGraphPin->SGraphPin mapping for the full pin set
PinToPinWidgetMap.Empty(PinToPinWidgetMap.Num());
for( TSet< TSharedRef<SWidget> >::TIterator ConnectorIt(AllPins); ConnectorIt; ++ConnectorIt )
{
const TSharedRef<SWidget>& SomePinWidget = *ConnectorIt;
const SGraphPin& PinWidget = static_cast<const SGraphPin&>(SomePinWidget.Get());
PinToPinWidgetMap.Add(PinWidget.GetPinObj(), StaticCastSharedRef<SGraphPin>(SomePinWidget));
}
}
// Now iterate over our lookup table to find the instances of pin widgets that we had previously linked to
TArray<TSharedRef<SGraphPin>> PinArray;
for(auto LinkedToPinInfoIter = LinkedToPinInfoArray.CreateConstIterator(); LinkedToPinInfoIter; ++LinkedToPinInfoIter)
{
LinkedToPinInfo PinInfo = *LinkedToPinInfoIter;
UEdGraphNode* OwnerNodeObj = PinInfo.OwnerNodePtr.Get();
if(OwnerNodeObj != NULL)
{
for(auto PinIter = PinInfo.OwnerNodePtr.Get()->Pins.CreateConstIterator(); PinIter; ++PinIter)
{
UEdGraphPin* Pin = *PinIter;
//.........这里部分代码省略.........
示例7: PrepForAutomatedBuild
/**
* Helper method designed to perform the necessary preparations required to complete an automated editor build
*
* @param BuildSettings Build settings that will be used for the editor build
* @param OutPkgsToSubmit Set of packages that need to be saved and submitted after a successful build
* @param OutErrorMessages Errors that resulted from the preparation (may or may not force the build to stop, depending on build settings)
*
* @return true if the preparation was successful and the build should continue; false if the preparation failed and the build should be aborted
*/
bool FEditorBuildUtils::PrepForAutomatedBuild( const FEditorAutomatedBuildSettings& BuildSettings, TSet<UPackage*>& OutPkgsToSubmit, FText& OutErrorMessages )
{
// Assume the preparation is successful to start
bool bBuildSuccessful = true;
OutPkgsToSubmit.Empty();
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// Source control is required for the automated build, so ensure that SCC support is compiled in and
// that the server is enabled and available for use
if ( !ISourceControlModule::Get().IsEnabled() || !SourceControlProvider.IsAvailable() )
{
bBuildSuccessful = false;
LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_SCCError", "Cannot connect to source control; automated build aborted."), OutErrorMessages );
}
// Empty changelists aren't allowed; abort the build if one wasn't provided
if ( bBuildSuccessful && BuildSettings.ChangeDescription.Len() == 0 )
{
bBuildSuccessful = false;
LogErrorMessage( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_NoCLDesc", "A changelist description must be provided; automated build aborted."), OutErrorMessages );
}
TArray<UPackage*> PreviouslySavedWorldPackages;
TArray<UPackage*> PackagesToCheckout;
TArray<ULevel*> LevelsToSave;
if ( bBuildSuccessful )
{
TArray<UWorld*> AllWorlds;
FString UnsavedWorlds;
EditorLevelUtils::GetWorlds( GWorld, AllWorlds, true );
// Check all of the worlds that will be built to ensure they have been saved before and have a filename
// associated with them. If they don't, they won't be able to be submitted to source control.
FString CurWorldPkgFileName;
for ( TArray<UWorld*>::TConstIterator WorldIter( AllWorlds ); WorldIter; ++WorldIter )
{
const UWorld* CurWorld = *WorldIter;
check( CurWorld );
UPackage* CurWorldPackage = CurWorld->GetOutermost();
check( CurWorldPackage );
if ( FPackageName::DoesPackageExist( CurWorldPackage->GetName(), NULL, &CurWorldPkgFileName ) )
{
PreviouslySavedWorldPackages.AddUnique( CurWorldPackage );
// Add all packages which have a corresponding file to the set of packages to submit for now. As preparation continues
// any packages that can't be submitted due to some error will be removed.
OutPkgsToSubmit.Add( CurWorldPackage );
}
else
{
UnsavedWorlds += FString::Printf( TEXT("%s\n"), *CurWorldPackage->GetName() );
}
}
// If any of the worlds haven't been saved before, process the build setting's behavior to see if the build
// should proceed or not
if ( UnsavedWorlds.Len() > 0 )
{
bBuildSuccessful = ProcessAutomatedBuildBehavior( BuildSettings.NewMapBehavior,
FText::Format( NSLOCTEXT("UnrealEd", "AutomatedBuild_Error_UnsavedMap", "The following levels have never been saved before and cannot be submitted:\n\n{0}\n\nAttempt to continue the build?"), FText::FromString(UnsavedWorlds) ),
OutErrorMessages );
}
}
// Load the asset tools module
FAssetToolsModule& AssetToolsModule = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
if ( bBuildSuccessful )
{
// Update the source control status of any relevant world packages in order to determine which need to be
// checked out, added to the depot, etc.
SourceControlProvider.Execute( ISourceControlOperation::Create<FUpdateStatus>(), SourceControlHelpers::PackageFilenames(PreviouslySavedWorldPackages) );
FString PkgsThatCantBeCheckedOut;
for ( TArray<UPackage*>::TConstIterator PkgIter( PreviouslySavedWorldPackages ); PkgIter; ++PkgIter )
{
UPackage* CurPackage = *PkgIter;
const FString CurPkgName = CurPackage->GetName();
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(CurPackage, EStateCacheUsage::ForceUpdate);
if( !SourceControlState.IsValid() ||
(!SourceControlState->IsSourceControlled() &&
!SourceControlState->IsUnknown() &&
!SourceControlState->IsIgnored()))
{
FString CurFilename;
//.........这里部分代码省略.........
示例8: SpawnMissingNodes
void UEnvironmentQueryGraph::SpawnMissingNodes()
{
UEnvQuery* QueryOwner = Cast<UEnvQuery>(GetOuter());
if (QueryOwner == nullptr)
{
return;
}
TSet<UEnvQueryTest*> ExistingTests;
TSet<UEnvQueryOption*> ExistingNodes;
TArray<UEnvQueryOption*> OptionsCopy = QueryOwner->GetOptions();
UAIGraphNode* MyRootNode = nullptr;
for (int32 Idx = 0; Idx < Nodes.Num(); Idx++)
{
UEnvironmentQueryGraphNode* MyNode = Cast<UEnvironmentQueryGraphNode>(Nodes[Idx]);
UEnvQueryOption* OptionInstance = MyNode ? Cast<UEnvQueryOption>(MyNode->NodeInstance) : nullptr;
if (OptionInstance && OptionInstance->Generator)
{
ExistingNodes.Add(OptionInstance);
ExistingTests.Empty(ExistingTests.Num());
for (int32 SubIdx = 0; SubIdx < MyNode->SubNodes.Num(); SubIdx++)
{
UEnvironmentQueryGraphNode* MySubNode = Cast<UEnvironmentQueryGraphNode>(MyNode->SubNodes[SubIdx]);
UEnvQueryTest* TestInstance = MySubNode ? Cast<UEnvQueryTest>(MySubNode->NodeInstance) : nullptr;
if (TestInstance)
{
ExistingTests.Add(TestInstance);
}
else
{
MyNode->RemoveSubNode(MySubNode);
SubIdx--;
}
}
SpawnMissingSubNodes(OptionInstance, ExistingTests, MyNode);
}
UEnvironmentQueryGraphNode_Root* RootNode = Cast<UEnvironmentQueryGraphNode_Root>(Nodes[Idx]);
if (RootNode)
{
MyRootNode = RootNode;
}
}
UEdGraphPin* RootOutPin = MyRootNode ? FindGraphNodePin(MyRootNode, EGPD_Output) : nullptr;
ExistingTests.Empty(0);
for (int32 Idx = 0; Idx < OptionsCopy.Num(); Idx++)
{
UEnvQueryOption* OptionInstance = OptionsCopy[Idx];
if (ExistingNodes.Contains(OptionInstance) || OptionInstance == nullptr || OptionInstance->Generator == nullptr)
{
continue;
}
FGraphNodeCreator<UEnvironmentQueryGraphNode_Option> NodeBuilder(*this);
UEnvironmentQueryGraphNode_Option* MyNode = NodeBuilder.CreateNode();
UAIGraphNode::UpdateNodeClassDataFrom(OptionInstance->Generator->GetClass(), MyNode->ClassData);
MyNode->ErrorMessage = MyNode->ClassData.GetDeprecatedMessage();
NodeBuilder.Finalize();
if (MyRootNode)
{
MyNode->NodePosX = MyRootNode->NodePosX + (Idx * 300);
MyNode->NodePosY = MyRootNode->NodePosY + 100;
}
MyNode->NodeInstance = OptionInstance;
SpawnMissingSubNodes(OptionInstance, ExistingTests, MyNode);
UEdGraphPin* SpawnedInPin = FindGraphNodePin(MyNode, EGPD_Input);
if (RootOutPin && SpawnedInPin)
{
RootOutPin->MakeLinkTo(SpawnedInPin);
}
}
}