本文整理汇总了C++中TArray::IndexOfByPredicate方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::IndexOfByPredicate方法的具体用法?C++ TArray::IndexOfByPredicate怎么用?C++ TArray::IndexOfByPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::IndexOfByPredicate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseStatusResults
/** Parse the array of strings results of a 'git status' command
*
* Example git status results:
M Content/Textures/T_Perlin_Noise_M.uasset
R Content/Textures/T_Perlin_Noise_M.uasset -> Content/Textures/T_Perlin_Noise_M2.uasset
?? Content/Materials/M_Basic_Wall.uasset
!! BasicCode.sln
*/
static void ParseStatusResults(const TArray<FString>& InFiles, const TArray<FString>& InResults, TArray<FGitSourceControlState>& OutStates)
{
// Iterate on all files explicitely listed in the command
for(const auto& File : InFiles)
{
FGitSourceControlState FileState(File);
// Search the file in the list of status
int32 IdxResult = InResults.IndexOfByPredicate(FGitStatusFileMatcher(File));
if(IdxResult != INDEX_NONE)
{
// File found in status results; only the case for "changed" files
FGitStatusParser StatusParser(InResults[IdxResult]);
FileState.WorkingCopyState = StatusParser.State;
}
else
{
// File not found in status
if(FPaths::FileExists(File))
{
// usually means the file is unchanged,
FileState.WorkingCopyState = EWorkingCopyState::Unchanged;
}
else
{
// but also the case for newly created content: there is no file on disk until the content is saved for the first time
FileState.WorkingCopyState = EWorkingCopyState::NotControlled;
}
}
FileState.TimeStamp.Now();
OutStates.Add(FileState);
}
}
示例2: CleanupUnitTestWorlds
void NUTNet::CleanupUnitTestWorlds()
{
for (auto It=PendingUnitWorldCleanup.CreateIterator(); It; ++It)
{
UWorld* CurWorld = *It;
// Remove the tick-hook, for this world
int32 TickHookIdx = ActiveTickHooks.IndexOfByPredicate(
[&CurWorld](const FWorldTickHook* CurTickHook)
{
return CurTickHook != NULL && CurTickHook->AttachedWorld == CurWorld;
});
if (TickHookIdx != INDEX_NONE)
{
ActiveTickHooks.RemoveAt(TickHookIdx);
}
GEngine->DestroyWorldContext(CurWorld);
CurWorld->DestroyWorld(false);
}
PendingUnitWorldCleanup.Empty();
// Immediately garbage collect remaining objects, to finish net driver cleanup
CollectGarbage(GARBAGE_COLLECTION_KEEPFLAGS, true);
}
示例3: UniqueIdToAddMatch
static inline void AddIdToMuteList(TArray< TSharedRef<const FUniqueNetId> >& MuteList, const TSharedPtr<const FUniqueNetId>& UniqueIdToAdd)
{
FUniqueNetIdMatcher UniqueIdToAddMatch(*UniqueIdToAdd);
if (MuteList.IndexOfByPredicate(UniqueIdToAddMatch) == INDEX_NONE)
{
MuteList.Add(UniqueIdToAdd.ToSharedRef());
}
}
示例4: UniqueIdToRemoveMatch
static inline void RemoveIdFromMuteList(TArray< TSharedRef<const FUniqueNetId> >& MuteList, const TSharedPtr<const FUniqueNetId>& UniqueIdToRemove)
{
FUniqueNetIdMatcher UniqueIdToRemoveMatch(*UniqueIdToRemove);
int32 RemoveIndex = MuteList.IndexOfByPredicate(UniqueIdToRemoveMatch);
if (RemoveIndex != INDEX_NONE)
{
MuteList.RemoveAtSwap(RemoveIndex);
}
}
示例5: AddSortedSpriteInfo
static void AddSortedSpriteInfo(TArray<FSpriteCategoryInfo>& InOutSortedSpriteInfo, const FSpriteCategoryInfo& InSpriteInfo )
{
const FSpriteCategoryInfo* ExistingSpriteInfo = InOutSortedSpriteInfo.FindByPredicate([&InSpriteInfo](const FSpriteCategoryInfo& SpriteInfo){ return InSpriteInfo.Category == SpriteInfo.Category; });
if (ExistingSpriteInfo != NULL)
{
//Already present
checkSlow(ExistingSpriteInfo->DisplayName.EqualTo(InSpriteInfo.DisplayName)); //Catch mismatches between DisplayNames
}
else
{
// Add the category to the correct position in the array to keep it sorted
const int32 CatIndex = InOutSortedSpriteInfo.IndexOfByPredicate([&InSpriteInfo](const FSpriteCategoryInfo& SpriteInfo){ return InSpriteInfo.DisplayName.CompareTo( SpriteInfo.DisplayName ) < 0; });
if (CatIndex != INDEX_NONE)
{
InOutSortedSpriteInfo.Insert( InSpriteInfo, CatIndex );
}
else
{
InOutSortedSpriteInfo.Add( InSpriteInfo );
}
}
}
示例6: GenerateExportScript
FLocalizationConfigurationScript GenerateExportScript(const FLocalizationTargetSettings& Target, const TOptional<FString> CultureName, const TOptional<FString> OutputPathOverride)
{
FLocalizationConfigurationScript Script;
const FString ContentDirRelativeToGameDir = MakePathRelativeToProjectDirectory(FPaths::GameContentDir());
// GatherTextStep0 - InternationalizationExport
{
FConfigSection& ConfigSection = Script.GatherTextStep(0);
// CommandletClass
ConfigSection.Add( TEXT("CommandletClass"), TEXT("InternationalizationExport") );
ConfigSection.Add( TEXT("bExportLoc"), TEXT("true") );
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
FString DestinationPath;
// Overriding output path changes the destination directory for the PO file.
if (OutputPathOverride.IsSet())
{
// The output path for a specific culture is a file path.
if (CultureName.IsSet())
{
DestinationPath = MakePathRelativeToProjectDirectory( FPaths::GetPath(OutputPathOverride.GetValue()) );
}
// Otherwise, it is a directory path.
else
{
DestinationPath = MakePathRelativeToProjectDirectory( OutputPathOverride.GetValue() );
}
}
// Use the default PO file's directory path.
else
{
DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target.Name;
}
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
TArray<const FCultureStatistics*> AllCultureStatistics;
AllCultureStatistics.Add(&Target.NativeCultureStatistics);
for (const FCultureStatistics& SupportedCultureStatistics : Target.SupportedCulturesStatistics)
{
AllCultureStatistics.Add(&SupportedCultureStatistics);
}
const auto& AddCultureToGenerate = [&](const int32 Index)
{
ConfigSection.Add( TEXT("CulturesToGenerate"), AllCultureStatistics[Index]->CultureName );
};
// Export for a specific culture.
if (CultureName.IsSet())
{
const int32 CultureIndex = AllCultureStatistics.IndexOfByPredicate([CultureName](const FCultureStatistics* Culture) { return Culture->CultureName == CultureName.GetValue(); });
AddCultureToGenerate(CultureIndex);
}
// Export for all cultures.
else
{
for (int32 CultureIndex = 0; CultureIndex < AllCultureStatistics.Num(); ++CultureIndex)
{
AddCultureToGenerate(CultureIndex);
}
}
// Do not use culture subdirectories if exporting a single culture to a specific directory.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
ConfigSection.Add( TEXT("bUseCultureDirectory"), "false" );
}
ConfigSection.Add( TEXT("ManifestName"), FPaths::GetCleanFilename(GetManifestPath(Target)) );
ConfigSection.Add( TEXT("ArchiveName"), FPaths::GetCleanFilename(GetArchivePath(Target, FString())) );
FString POFileName;
// The output path for a specific culture is a file path.
if (CultureName.IsSet() && OutputPathOverride.IsSet())
{
POFileName = FPaths::GetCleanFilename( OutputPathOverride.GetValue() );
}
// Use the default PO file's name.
else
{
POFileName = FPaths::GetCleanFilename( GetDefaultPOPath( Target, CultureName.Get( TEXT("") ) ) );
}
ConfigSection.Add( TEXT("PortableObjectName"), POFileName );
}
Script.Dirty = true;
return Script;
}
示例7: FIntPoint
TArray<FArrangedWidget> FHittestGrid::GetBubblePath( FVector2D DesktopSpaceCoordinate, bool bIgnoreEnabledStatus )
{
if (WidgetsCachedThisFrame->Num() > 0 && Cells.Num() > 0)
{
const FVector2D CursorPositionInGrid = DesktopSpaceCoordinate - GridOrigin;
const FIntPoint CellCoordinate = FIntPoint(
FMath::Min( FMath::Max(FMath::FloorToInt(CursorPositionInGrid.X / CellSize.X), 0), NumCells.X-1),
FMath::Min( FMath::Max(FMath::FloorToInt(CursorPositionInGrid.Y / CellSize.Y), 0), NumCells.Y-1 ) );
static FVector2D LastCoordinate = FVector2D::ZeroVector;
if ( LastCoordinate != CursorPositionInGrid )
{
LastCoordinate = CursorPositionInGrid;
}
checkf( (CellCoordinate.Y*NumCells.X + CellCoordinate.X) < Cells.Num(), TEXT("Index out of range, CellCoordinate is: %d %d CursorPosition is: %f %f"), CellCoordinate.X, CellCoordinate.Y, CursorPositionInGrid.X, CursorPositionInGrid.Y );
const TArray<int32>& IndexesInCell = CellAt( CellCoordinate.X, CellCoordinate.Y ).CachedWidgetIndexes;
int32 HitWidgetIndex = INDEX_NONE;
// Consider front-most widgets first for hittesting.
for ( int32 i = IndexesInCell.Num()-1; i>=0 && HitWidgetIndex==INDEX_NONE; --i )
{
check( IndexesInCell[i] < WidgetsCachedThisFrame->Num() );
const FCachedWidget& TestCandidate = (*WidgetsCachedThisFrame)[IndexesInCell[i]];
// Compute the render space clipping rect (FGeometry exposes a layout space clipping rect).
FSlateRotatedRect DesktopOrientedClipRect =
TransformRect(
Concatenate(
Inverse(TestCandidate.CachedGeometry.GetAccumulatedLayoutTransform()),
TestCandidate.CachedGeometry.GetAccumulatedRenderTransform()
),
FSlateRotatedRect(TestCandidate.CachedGeometry.GetClippingRect().IntersectionWith(TestCandidate.ClippingRect))
);
if (DesktopOrientedClipRect.IsUnderLocation(DesktopSpaceCoordinate) && TestCandidate.WidgetPtr.IsValid())
{
HitWidgetIndex = IndexesInCell[i];
}
}
if (HitWidgetIndex != INDEX_NONE)
{
TArray<FArrangedWidget> BubblePath;
int32 CurWidgetIndex=HitWidgetIndex;
bool bPathUninterrupted = false;
do
{
check( CurWidgetIndex < WidgetsCachedThisFrame->Num() );
const FCachedWidget& CurCachedWidget = (*WidgetsCachedThisFrame)[CurWidgetIndex];
const TSharedPtr<SWidget> CachedWidgetPtr = CurCachedWidget.WidgetPtr.Pin();
bPathUninterrupted = CachedWidgetPtr.IsValid();
if (bPathUninterrupted)
{
BubblePath.Insert(FArrangedWidget(CachedWidgetPtr.ToSharedRef(), CurCachedWidget.CachedGeometry), 0);
CurWidgetIndex = CurCachedWidget.ParentIndex;
}
}
while (CurWidgetIndex != INDEX_NONE && bPathUninterrupted);
if (!bPathUninterrupted)
{
// A widget in the path to the root has been removed, so anything
// we thought we had hittest is no longer actually there.
// Pretend we didn't hit anything.
BubblePath = TArray<FArrangedWidget>();
}
// Disabling a widget disables all of its logical children
// This effect is achieved by truncating the path to the
// root-most enabled widget.
if ( !bIgnoreEnabledStatus )
{
const int32 DisabledWidgetIndex = BubblePath.IndexOfByPredicate( []( const FArrangedWidget& SomeWidget ){ return !SomeWidget.Widget->IsEnabled( ); } );
if (DisabledWidgetIndex != INDEX_NONE)
{
BubblePath.RemoveAt( DisabledWidgetIndex, BubblePath.Num() - DisabledWidgetIndex );
}
}
return BubblePath;
}
else
{
return TArray<FArrangedWidget>();
}
}
else
{
return TArray<FArrangedWidget>();
}
}