本文整理汇总了C++中TArray::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::Find方法的具体用法?C++ TArray::Find怎么用?C++ TArray::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsCategoryHiddenFromClass
//------------------------------------------------------------------------------
bool FEditorCategoryUtils::IsCategoryHiddenFromClass(UClass const* Class, FString const& Category)
{
bool bIsHidden = false;
TArray<FString> ClassHideCategories;
GetClassHideCategories(Class, ClassHideCategories);
// run the category through sanitization so we can ensure compares will hit
FString const DisplayCategory = GetCategoryDisplayString(Category);
for (FString& HideCategory : ClassHideCategories)
{
bIsHidden = (HideCategory == DisplayCategory);
if (bIsHidden)
{
TArray<FString> ClassShowCategories;
GetClassShowCategories(Class, ClassShowCategories);
// if they hid it, and showed it... favor showing (could be a shown in a sub-class, and hid in a super)
bIsHidden = (ClassShowCategories.Find(DisplayCategory) == INDEX_NONE);
}
else // see if the category's root is hidden
{
TArray<FString> SubCategoryList;
DisplayCategory.ParseIntoArray(&SubCategoryList, TEXT("|"), /*InCullEmpty =*/true);
FString FullSubCategoryPath;
for (FString const& SubCategory : SubCategoryList)
{
FullSubCategoryPath += SubCategory;
if ((HideCategory == SubCategory) || (HideCategory == FullSubCategoryPath))
{
TArray<FString> ClassShowCategories;
GetClassShowCategories(Class, ClassShowCategories);
// if they hid it, and showed it... favor showing (could be a shown in a sub-class, and hid in a super)
bIsHidden = (ClassShowCategories.Find(DisplayCategory) == INDEX_NONE);
}
FullSubCategoryPath += "|";
}
}
if (bIsHidden)
{
break;
}
}
return bIsHidden;
}
示例2: InsertRecursive
/**
* Recursively look for `TargetItem` in `InsertInto` and any of the descendants.
* Insert `ItemToInsert` relative to the target.
* Relative positioning dictated by `RelativeLocation`.
*
* @return true when successful.
*/
static bool InsertRecursive(TArray< TSharedPtr< FTestData > >& InsertInto, const TSharedRef<FTestData>& ItemToInsert, const TSharedRef<FTestData>& TargetItem, EItemDropZone RelativeLocation)
{
const int32 TargetIndex = InsertInto.Find(TargetItem);
if (TargetIndex != INDEX_NONE)
{
if (RelativeLocation == EItemDropZone::AboveItem)
{
InsertInto.Insert(ItemToInsert, TargetIndex);
}
else if (RelativeLocation == EItemDropZone::BelowItem)
{
InsertInto.Insert(ItemToInsert, TargetIndex + 1);
}
else
{
ensure(RelativeLocation == EItemDropZone::OntoItem);
InsertInto[TargetIndex]->Children.Insert(ItemToInsert, 0);
}
return true;
}
// Did not successfully remove an item. Try all the children.
for (int32 ItemIndex = 0; ItemIndex < InsertInto.Num(); ++ItemIndex)
{
if (InsertRecursive(InsertInto[ItemIndex]->Children, ItemToInsert, TargetItem, RelativeLocation))
{
return true;
}
}
return false;
}
示例3: Apply
/**
* Enacts the transaction.
*/
void FTransaction::Apply()
{
checkSlow(Inc==1||Inc==-1);
// Figure out direction.
const int32 Start = Inc==1 ? 0 : Records.Num()-1;
const int32 End = Inc==1 ? Records.Num() : -1;
// Init objects.
TArray<UObject*> ChangedObjects;
for( int32 i=Start; i!=End; i+=Inc )
{
Records[i].bRestored = false;
if(ChangedObjects.Find(Records[i].Object) == INDEX_NONE)
{
Records[i].Object->CheckDefaultSubobjects();
Records[i].Object->PreEditUndo();
ChangedObjects.Add(Records[i].Object);
}
}
for( int32 i=Start; i!=End; i+=Inc )
{
Records[i].Restore( this );
}
NumModelsModified = 0; // Count the number of UModels that were changed.
for(int32 ObjectIndex = 0;ObjectIndex < ChangedObjects.Num();ObjectIndex++)
{
UObject* ChangedObject = ChangedObjects[ObjectIndex];
UModel* Model = Cast<UModel>(ChangedObject);
if( Model && Model->Nodes.Num() )
{
FBSPOps::bspBuildBounds( Model );
++NumModelsModified;
}
ChangedObject->PostEditUndo();
}
// Rebuild BSP here instead of waiting for the next tick since
// multiple transaction events can occur in a single tick
if (ABrush::NeedsRebuild())
{
GEditor->RebuildAlteredBSP();
}
// Flip it.
if( bFlip )
{
Inc *= -1;
}
for(int32 ObjectIndex = 0;ObjectIndex < ChangedObjects.Num();ObjectIndex++)
{
UObject* ChangedObject = ChangedObjects[ObjectIndex];
ChangedObject->CheckDefaultSubobjects();
}
}
示例4: AddStationTable
void CSystemCreateStats::AddStationTable (CSystem *pSystem, const CString &sStationCriteria, const CString &sLocationAttribs, TArray<CStationTableCache::SEntry> &Table)
// AddStationTable
//
// Adds the station table.
{
int i;
// See if we already have an entry for this table.
// If we don't we add it.
SEncounterTable *pEntry;
if (!FindEncounterTable(Table, &pEntry))
{
pEntry = m_EncounterTables.Insert();
pEntry->iLevel = pSystem->GetLevel();
pEntry->pSystemType = pSystem->GetType();
pEntry->sStationCriteria = sStationCriteria;
pEntry->iCount = 1;
ParseAttributes(sLocationAttribs, &pEntry->LabelAttribs);
pEntry->bHasStation = false;
for (i = 0; i < Table.GetCount(); i++)
{
pEntry->Table.Insert(Table[i].pType, Table[i].iChance);
if (Table[i].pType->GetScale() == scaleStructure
|| Table[i].pType->GetScale() == scaleShip)
pEntry->bHasStation = true;
}
return;
}
// If we already have the table we need to aggregate the entry. We start
// by incrementing the count.
pEntry->iCount++;
// Next we remove any location/label attributes that are not common to
// both tables. [We assume that if we have two identical tables then only
// the attributes in common count to make the table unique.]
TArray<CString> NewAttribs;
ParseAttributes(sLocationAttribs, &NewAttribs);
for (i = 0; i < pEntry->LabelAttribs.GetCount(); i++)
{
if (!NewAttribs.Find(pEntry->LabelAttribs[i]))
{
pEntry->LabelAttribs.Delete(i);
i--;
}
}
}
示例5: GetAttributes
void UNiagaraGraph::GetAttributes(TArray< FNiagaraVariableInfo >& OutAttributes)const
{
const UNiagaraNodeOutput* OutNode = FindOutputNode();
check(OutNode);
for (const FNiagaraVariableInfo& Attr : OutNode->Outputs)
{
check(!OutAttributes.Find(Attr));
OutAttributes.Add(Attr);
}
}
示例6: GetColorForCategory
FLinearColor FLogVisualizer::GetColorForCategory(const FString& InFilterName) const
{
static TArray<FString> Filters;
int32 CategoryIndex = Filters.Find(InFilterName);
if (CategoryIndex == INDEX_NONE)
{
CategoryIndex = Filters.Add(InFilterName);
}
return GetColorForCategory(CategoryIndex);
}
示例7: AccumulateEnhancements
bool CDeviceClass::AccumulateEnhancements (CItemCtx &Device, CInstalledDevice *pTarget, TArray<CString> &EnhancementIDs, CItemEnhancementStack *pEnhancements)
// AccumulateEnhancements
//
// If this device can enhance pTarget, then we add to the list of enhancements.
{
int i;
bool bEnhanced = false;
CInstalledDevice *pDevice = Device.GetDevice();
CSpaceObject *pSource = Device.GetSource();
// See if we can enhance the target device
if (pDevice == NULL
|| (pDevice->IsEnabled() && !pDevice->IsDamaged()))
{
for (i = 0; i < m_Enhancements.GetCount(); i++)
{
// If this type of enhancement has already been applied, skip it
if (!m_Enhancements[i].sType.IsBlank()
&& EnhancementIDs.Find(m_Enhancements[i].sType))
continue;
// If we don't match the criteria, skip it.
if (pSource
&& pTarget
&& !pSource->GetItemForDevice(pTarget).MatchesCriteria(m_Enhancements[i].Criteria))
continue;
// Add the enhancement
pEnhancements->Insert(m_Enhancements[i].Enhancement);
bEnhanced = true;
// Remember that we added this enhancement class
if (!m_Enhancements[i].sType.IsBlank())
EnhancementIDs.Insert(m_Enhancements[i].sType);
}
}
// Let sub-classes add their own
if (OnAccumulateEnhancements(Device, pTarget, EnhancementIDs, pEnhancements))
bEnhanced = true;
// Done
return bEnhanced;
}
示例8: OnObjectSelectionChanged
void SVisualLoggerTimelinesContainer::OnObjectSelectionChanged(const TArray<FName>& RowNames)
{
CachedSelectedTimelines.Reset();
for (TSharedPtr<SLogVisualizerTimeline>& Timeline : TimelineItems)
{
if (RowNames.Find(Timeline->GetName()) != INDEX_NONE)
{
CachedSelectedTimelines.Add(Timeline);
}
}
if (CachedSelectedTimelines.Num() >= 1)
{
FSlateApplication::Get().SetKeyboardFocus(SharedThis(CachedSelectedTimelines[CachedSelectedTimelines.Num()-1].Get()), EFocusCause::Navigation);
}
}
示例9: Generate
/** Add items to the output object array according to the input object set */
void Generate(EStaticMeshLightingInfoObjectSets InObjectSet, TArray< TWeakObjectPtr<UObject> >& OutObjects)
{
/** The levels we are gathering information for. */
TArray<ULevel*> Levels;
UWorld* World = GWorld;
// Fill the light list
for (TObjectIterator<ULightComponent> LightIt; LightIt; ++LightIt)
{
ULightComponent* const Light = *LightIt;
const bool bLightIsInWorld = Light->GetOwner() && !Light->GetOwner()->HasAnyFlags(RF_ClassDefaultObject) && World->ContainsActor(Light->GetOwner());
if (bLightIsInWorld)
{
if (Light->HasStaticLighting() || Light->HasStaticShadowing())
{
// Add the light to the system's list of lights in the world.
AllLights.Add(Light);
}
//append to the list of levels in use
AddRequiredLevels( InObjectSet, World, Levels );
}
}
if (Levels.Num() > 0)
{
// Iterate over static mesh components in the list of levels...
for (TObjectIterator<UStaticMeshComponent> SMCIt; SMCIt; ++SMCIt)
{
AActor* Owner = Cast<AActor>( (*SMCIt)->GetOwner() );
if (Owner && !Owner->HasAnyFlags(RF_ClassDefaultObject) )
{
int32 Dummy;
ULevel* CheckLevel = Owner->GetLevel();
if ((CheckLevel != NULL) && (Levels.Find(CheckLevel, Dummy)))
{
AddItem(*SMCIt, Owner, OutObjects);
}
}
}
}
}
示例10: CurrentDifference
int32 DiffTreeView::CurrentDifference(TSharedRef< STreeView<TSharedPtr< FBlueprintDifferenceTreeEntry > > > TreeView, const TArray< TSharedPtr<class FBlueprintDifferenceTreeEntry> >& Differences)
{
auto SelectedItems = TreeView->GetSelectedItems();
if (SelectedItems.Num() == 0)
{
return INDEX_NONE;
}
for (int32 Iter = 0; Iter < SelectedItems.Num(); ++Iter)
{
int32 Index = Differences.Find(SelectedItems[Iter]);
if (Index != INDEX_NONE)
{
return Index;
}
}
return INDEX_NONE;
}
示例11: OnDrop
void FStreamingLevelModel::OnDrop(const TSharedPtr<FLevelDragDropOp>& Op)
{
TArray<ULevelStreaming*> DropStreamingLevels;
for (auto It = Op->StreamingLevelsToDrop.CreateConstIterator(); It; ++It)
{
if ((*It).IsValid())
{
DropStreamingLevels.AddUnique((*It).Get());
}
}
// Prevent dropping items on itself
if (DropStreamingLevels.Num() && DropStreamingLevels.Find(LevelStreaming.Get()) == INDEX_NONE)
{
UWorld* CurrentWorld = LevelCollectionModel.GetWorld();
auto& WorldStreamingLevels = CurrentWorld->StreamingLevels;
// Remove streaming level objects from a world streaming levels list
for (auto It : DropStreamingLevels)
{
WorldStreamingLevels.Remove(It);
}
// Find a new place where to insert the in a world streaming levels list
// Right after the current level, or at start of the list in case if this is persistent level
int32 InsertIndex = WorldStreamingLevels.Find(LevelStreaming.Get());
if (InsertIndex == INDEX_NONE)
{
InsertIndex = 0;
}
else
{
InsertIndex++;
}
WorldStreamingLevels.Insert(DropStreamingLevels, InsertIndex);
CurrentWorld->MarkPackageDirty();
// Force levels list refresh
LevelCollectionModel.PopulateLevelsList();
}
}
示例12: RemoveRecursive
/**
* Recursively look for `ItemToRemove` in `RemoveFrom` and any of the descendants, and remove `ItemToRemove`.
* @return true when successful.
*/
static bool RemoveRecursive(TArray< TSharedPtr< FTestData > >& RemoveFrom, const TSharedPtr<FTestData>& ItemToRemove)
{
int32 ItemIndex = RemoveFrom.Find(ItemToRemove);
if (ItemIndex != INDEX_NONE)
{
RemoveFrom.RemoveAt(ItemIndex);
return true;
}
// Did not successfully remove an item. Try all the children.
for (ItemIndex = 0; ItemIndex < RemoveFrom.Num(); ++ItemIndex)
{
if (RemoveRecursive(RemoveFrom[ItemIndex]->Children, ItemToRemove))
{
return true;
}
}
return false;
}
示例13: GetTargetFunction
void UK2Node_CallArrayFunction::GetArrayTypeDependentPins(TArray<UEdGraphPin*>& OutPins) const
{
OutPins.Empty();
UFunction* TargetFunction = GetTargetFunction();
check(TargetFunction);
const FString DependentPinMetaData = TargetFunction->GetMetaData(FBlueprintMetadata::MD_ArrayDependentParam);
TArray<FString> TypeDependentPinNames;
DependentPinMetaData.ParseIntoArray(TypeDependentPinNames, TEXT(","), true);
for(TArray<UEdGraphPin*>::TConstIterator it(Pins); it; ++it)
{
UEdGraphPin* CurrentPin = *it;
int32 ItemIndex = 0;
if( CurrentPin && TypeDependentPinNames.Find(CurrentPin->PinName, ItemIndex) )
{
OutPins.Add(CurrentPin);
}
}
}
示例14: GetFormatPin
void UK2Node_FormatText::PinDefaultValueChanged(UEdGraphPin* Pin)
{
const auto FormatPin = GetFormatPin();
if(Pin == FormatPin && FormatPin->LinkedTo.Num() == 0)
{
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
TArray< FString > ArgumentParams;
FText::GetFormatPatternParameters(FormatPin->DefaultTextValue, ArgumentParams);
PinNames.Empty();
for(auto It = ArgumentParams.CreateConstIterator(); It; ++It)
{
if(!FindArgumentPin(FText::FromString(*It)))
{
CreatePin(EGPD_Input, K2Schema->PC_Text, TEXT(""), NULL, false, false, *It);
}
PinNames.Add(FText::AsCultureInvariant(*It));
}
for(auto It = Pins.CreateConstIterator(); It; ++It)
{
UEdGraphPin* CheckPin = *It;
if(CheckPin != FormatPin && CheckPin->Direction == EGPD_Input)
{
int Index = 0;
if(!ArgumentParams.Find(CheckPin->PinName, Index))
{
CheckPin->BreakAllPinLinks();
Pins.Remove(CheckPin);
--It;
}
}
}
GetGraph()->NotifyGraphChanged();
}
}
示例15: ProcessBone
void FBoneHierarchyBuilder::ProcessBone(FName BoneName, int32 ExpectedParentIndex, const FTransform& InitialTransform, const FString& AnimationNameForErrors, int32 TimeForErrors)
{
const int32 BoneNameAlreadyInsertedIndex = AllBones.Find(BoneName);
if (BoneNameAlreadyInsertedIndex == INDEX_NONE)
{
if (ExpectedParentIndex == INDEX_NONE)
{
RootBones.Add(BoneName);
}
AllBones.Add(BoneName);
ParentIndices.Add(ExpectedParentIndex);
Transforms.Add(InitialTransform);
}
else
{
// Verify that the hierarchy hasn't changed
if (ParentIndices[BoneNameAlreadyInsertedIndex] != ExpectedParentIndex)
{
UE_LOG(LogInit, Warning, TEXT("Bone hierarchy (for bone '%s') in animation '%s' was changed at time %d ms. This change will be ignored and the animation will not play properly."), *BoneName.ToString(), *AnimationNameForErrors, TimeForErrors);
}
}
}