当前位置: 首页>>代码示例>>C++>>正文


C++ TArray::ContainsByPredicate方法代码示例

本文整理汇总了C++中TArray::ContainsByPredicate方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::ContainsByPredicate方法的具体用法?C++ TArray::ContainsByPredicate怎么用?C++ TArray::ContainsByPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TArray的用法示例。


在下文中一共展示了TArray::ContainsByPredicate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFormatArgumentNames_NoLock

void FTextFormatData::GetFormatArgumentNames_NoLock(TArray<FString>& OutArgumentNames)
{
	ConditionalCompile_NoLock();

	if (CompiledExpressionType != FTextFormat::EExpressionType::Complex)
	{
		return;
	}

	for (const FExpressionToken& Token : LexedExpression)
	{
		if (const auto* ArgumentToken = Token.Node.Cast<TextFormatTokens::FArgumentTokenSpecifier>())
		{
			// Add the entry to the array if it doesn't already exist
			// We can't just use AddUnique since we need the names to be case-sensitive
			const bool bIsInArray = OutArgumentNames.ContainsByPredicate([&](const FString& InEntry) -> bool
			{
				return ArgumentToken->ArgumentNameLen == InEntry.Len() && FCString::Strnicmp(ArgumentToken->ArgumentNameStartPos, *InEntry, ArgumentToken->ArgumentNameLen) == 0;
			});

			if (!bIsInArray)
			{
				OutArgumentNames.Add(FString(ArgumentToken->ArgumentNameLen, ArgumentToken->ArgumentNameStartPos));
			}
		}
		else if (const auto* ArgumentModifierToken = Token.Node.Cast<TextFormatTokens::FArgumentModifierTokenSpecifier>())
		{
			ArgumentModifierToken->TextFormatArgumentModifier->GetFormatArgumentNames(OutArgumentNames);
		}
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:31,代码来源:TextFormatter.cpp

示例2: ExecuteSCCSync

void FPathContextMenu::ExecuteSCCSync() const
{
	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();

	TArray<FString> RootPaths;
	FPackageName::QueryRootContentPaths( RootPaths );

	// find valid paths on disk
	TArray<FString> PathsOnDisk;
	for(const auto& SelectedPath : SelectedPaths)
	{
		// note: we make sure to terminate our path here so root directories map correctly.
		const FString CompletePath = SelectedPath / "";

		const bool bMatchesRoot = RootPaths.ContainsByPredicate([&](const FString& RootPath){ return CompletePath.StartsWith(RootPath); });
		if(bMatchesRoot)
		{
			FString PathOnDisk = FPackageName::LongPackageNameToFilename(CompletePath);
			PathsOnDisk.Add(PathOnDisk);
		}
	}

	if ( PathsOnDisk.Num() > 0 )
	{
		// attempt to unload all assets under this path
		TArray<FString> PackageNames;
		GetPackageNamesInSelectedPaths(PackageNames);

		// Form a list of loaded packages to prompt for save
		TArray<UPackage*> LoadedPackages;
		for( const auto& PackageName : PackageNames )
		{
			UPackage* Package = FindPackage(nullptr, *PackageName);
			if ( Package != nullptr )
			{
				LoadedPackages.Add(Package);
			}
		}

		FText ErrorMessage;
		PackageTools::UnloadPackages(LoadedPackages, ErrorMessage);

		if(!ErrorMessage.IsEmpty())
		{
			FMessageDialog::Open( EAppMsgType::Ok, ErrorMessage );
		}
		else
		{
			SourceControlProvider.Execute(ISourceControlOperation::Create<FSync>(), PathsOnDisk);
		}
	}
	else
	{
		UE_LOG(LogContentBrowser, Warning, TEXT("Couldn't find any valid paths to sync."))
	}
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:56,代码来源:PathContextMenu.cpp

示例3: TryAddFeaturePackCategory

void FFeaturePackContentSource::TryAddFeaturePackCategory(FString CategoryTitle, TArray< TSharedPtr<FSearchEntry> >& OutSuggestions)
{
	if (OutSuggestions.ContainsByPredicate([&CategoryTitle](TSharedPtr<FSearchEntry>& InElement)
		{ return ((InElement->Title == CategoryTitle) && (InElement->bCategory == true)); }) == false)
	{
		TSharedPtr<FSearchEntry> FeaturePackCat = MakeShareable(new FSearchEntry());
		FeaturePackCat->bCategory = true;
		FeaturePackCat->Title = CategoryTitle;
		OutSuggestions.Add(FeaturePackCat);
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:11,代码来源:FeaturePackContentSource.cpp

示例4: SetAllRoads

void UCarlaSettingsDelegate::SetAllRoads(UWorld* world, const float max_draw_distance, const TArray<FStaticMaterial> &road_pieces_materials) const
{
  if(!world||!IsValid(world)||world->IsPendingKill()) return;
  AsyncTask(ENamedThreads::GameThread, [=](){
    if(!world||!IsValid(world)||world->IsPendingKill()) return;
    TArray<AActor*> actors;
    UGameplayStatics::GetAllActorsWithTag(world, UCarlaSettings::CARLA_ROAD_TAG,actors);
    
    for(int32 i=0; i<actors.Num(); i++)
    {
      AActor* actor = actors[i];
      if(!IsValid(actor) || actor->IsPendingKill()) continue;
      TArray<UActorComponent*> components = actor->GetComponentsByClass(UStaticMeshComponent::StaticClass());
      for(int32 j=0; j<components.Num(); j++)
      {
        UStaticMeshComponent* staticmeshcomponent = Cast<UStaticMeshComponent>(components[j]);
        if(staticmeshcomponent)
        {
          staticmeshcomponent->bAllowCullDistanceVolume = (max_draw_distance>0);
          staticmeshcomponent->bUseAsOccluder = false;
          staticmeshcomponent->LDMaxDrawDistance = max_draw_distance; 
            staticmeshcomponent->CastShadow = (max_draw_distance==0);
          if(road_pieces_materials.Num()>0)
          {
            TArray<FName> meshslotsnames = staticmeshcomponent->GetMaterialSlotNames();
            for(int32 k=0; k<meshslotsnames.Num(); k++)
            {
              const FName &slotname = meshslotsnames[k];
              road_pieces_materials.ContainsByPredicate(
            [staticmeshcomponent,slotname](const FStaticMaterial& material)
              {
                if(material.MaterialSlotName.IsEqual(slotname))
                {
                  staticmeshcomponent->SetMaterial(
                    staticmeshcomponent->GetMaterialIndex(slotname), 
                    material.MaterialInterface
                  );
                  return true;
                } else return false;
              });
            }
          }
        }
      }
    }
  }); //,DELAY_TIME_TO_SET_ALL_ROADS, false);
}
开发者ID:cyy1991,项目名称:carla,代码行数:47,代码来源:CarlaSettingsDelegate.cpp

示例5: ShouldEvaluateIfOverlapping

bool FMovieSceneCinematicShotTrackInstance::ShouldEvaluateIfOverlapping(const TArray<UMovieSceneSection*>& TraversedSections, UMovieSceneSection* Section) const
{
	// Check with this shot's exclusive upper bound for when shots are adjacent to each other but on different rows.
	TRange<float> ThisSectionWithExclusiveUpper = TRange<float>(Section->GetRange().GetLowerBoundValue(), Section->GetRange().GetUpperBoundValue());

	// Only evaluate the top most row on overlapping cinematic shot sections. Disregard overlap priority.
	const bool bShouldRemove = TraversedSections.ContainsByPredicate([=](UMovieSceneSection* OtherSection){
		if (Section->GetRowIndex() > OtherSection->GetRowIndex() &&
			ThisSectionWithExclusiveUpper.Overlaps(OtherSection->GetRange()))
		{
			return true;
		}
		return false;
	});

	return bShouldRemove;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:17,代码来源:MovieSceneCinematicShotTrackInstance.cpp

示例6: IsCloseToPlayer

bool ACoverActor::IsCloseToPlayer(FName SocketName)
{
	//Perform a raycast in order to determine if the player is 
	//near the given socket
	TArray<FHitResult> HitResults;

	const FVector StartLocation = SM->GetSocketLocation(SocketName);

	const FVector EndLocation = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)->GetActorLocation();

	FCollisionShape Shape;
	Shape.ShapeType = ECollisionShape::Line;

	GetWorld()->SweepMultiByChannel(HitResults, StartLocation, EndLocation, FQuat(), ECC_WorldDynamic, Shape);

	//If our raycast contains the character inside its hit result
	//the character can take cover in the side that this socket represents
	return HitResults.ContainsByPredicate([&](FHitResult hitResult)
	{
		AActor* HitActor = hitResult.GetActor();
		return HitActor && HitActor->IsA<ACoverSystemCharacter>();
	});
}
开发者ID:orfeasel,项目名称:UE4-Game-Systems,代码行数:23,代码来源:CoverActor.cpp

示例7: DeleteRedirectors

void FAssetFixUpRedirectors::DeleteRedirectors(TArray<FRedirectorRefs>& RedirectorsToFix, const TArray<UPackage*>& FailedToSave) const
{
	TArray<UObject*> ObjectsToDelete;
	for ( auto RedirectorIt = RedirectorsToFix.CreateIterator(); RedirectorIt; ++RedirectorIt )
	{
		FRedirectorRefs& RedirectorRefs = *RedirectorIt;
		if ( RedirectorRefs.bRedirectorValidForFixup )
		{
			bool bAllReferencersFixedUp = true;
			for (const auto& ReferencingPackageName : RedirectorRefs.ReferencingPackageNames)
			{
				if (FailedToSave.ContainsByPredicate([&](UPackage* Package) { return Package->GetFName() == ReferencingPackageName; }))
				{
					bAllReferencersFixedUp = false;
					break;
				}
			}

			if (!bAllReferencersFixedUp)
			{
				continue;
			}

			// Add all redirectors found in this package to the redirectors to delete list.
			// All redirectors in this package should be fixed up.
			UPackage* RedirectorPackage = RedirectorRefs.Redirector->GetOutermost();
			TArray<UObject*> AssetsInRedirectorPackage;
			GetObjectsWithOuter(RedirectorPackage, AssetsInRedirectorPackage, /*bIncludeNestedObjects=*/false);
			UMetaData* PackageMetaData = NULL;
			bool bContainsAtLeastOneOtherAsset = false;
			for ( auto ObjIt = AssetsInRedirectorPackage.CreateConstIterator(); ObjIt; ++ObjIt )
			{
				if ( UObjectRedirector* Redirector = Cast<UObjectRedirector>(*ObjIt) )
				{
					Redirector->RemoveFromRoot();
					ObjectsToDelete.Add(Redirector);
				}
				else if ( UMetaData* MetaData = Cast<UMetaData>(*ObjIt) )
				{
					PackageMetaData = MetaData;
				}
				else
				{
					bContainsAtLeastOneOtherAsset = true;
				}
			}

			if ( !bContainsAtLeastOneOtherAsset )
			{
				RedirectorPackage->RemoveFromRoot();

				// @todo we shouldnt be worrying about metadata objects here, ObjectTools::CleanUpAfterSuccessfulDelete should
				if ( PackageMetaData )
				{
					PackageMetaData->RemoveFromRoot();
					ObjectsToDelete.Add(PackageMetaData);
				}
			}

			// This redirector will be deleted, NULL the reference here
			RedirectorRefs.Redirector = NULL;
		}
	}

	if ( ObjectsToDelete.Num() > 0 )
	{
		ObjectTools::DeleteObjects(ObjectsToDelete, false);
	}
}
开发者ID:PopCap,项目名称:GameIdea,代码行数:69,代码来源:AssetFixUpRedirectors.cpp

示例8: ReportLoadedAudioAssets

bool LocalizationCommandletTasks::ReportLoadedAudioAssets(const TArray<ULocalizationTarget*>& Targets, const TOptional<FString>& CultureName)
{
	TSet<FString> LoadedDialogueWaveAssets;
	TSet<FString> LoadedSoundWaveAssets;

	for (const ULocalizationTarget* Target : Targets)
	{
		const FString RootAssetPath = Target->IsMemberOfEngineTargetSet() ? TEXT("/Engine") : TEXT("/Game");

		TArray<FString> CulturesToTest;
		{
			if (CultureName.IsSet())
			{
				CulturesToTest.Add(CultureName.GetValue());
			}
			else
			{
				CulturesToTest.Reserve(Target->Settings.SupportedCulturesStatistics.Num());
				for (const FCultureStatistics& CultureData : Target->Settings.SupportedCulturesStatistics)
				{
					CulturesToTest.Add(CultureData.CultureName);
				}
			}
		}

		TArray<FString> DialogueWavePathsToTest;
		TArray<FString> SoundWavePathsToTest;
		{
			const FString NativeCulture = Target->Settings.SupportedCulturesStatistics.IsValidIndex(Target->Settings.NativeCultureIndex) ? Target->Settings.SupportedCulturesStatistics[Target->Settings.NativeCultureIndex].CultureName : FString();
			const bool bImportNativeAsSource = Target->Settings.ImportDialogueSettings.bImportNativeAsSource && !NativeCulture.IsEmpty();
			if (bImportNativeAsSource)
			{
				DialogueWavePathsToTest.Add(RootAssetPath);
				SoundWavePathsToTest.Add(RootAssetPath / Target->Settings.ImportDialogueSettings.ImportedDialogueFolder);
			}

			for (const FString& Culture : CulturesToTest)
			{
				if (bImportNativeAsSource && Culture == NativeCulture)
				{
					continue;
				}

				DialogueWavePathsToTest.Add(RootAssetPath / TEXT("L10N") / Culture);
				SoundWavePathsToTest.Add(RootAssetPath / TEXT("L10N") / Culture / Target->Settings.ImportDialogueSettings.ImportedDialogueFolder);
			}
		}

		ForEachObjectOfClass(UDialogueWave::StaticClass(), [&](UObject* InObject)
		{
			const FString ObjectPath = InObject->GetPathName();

			auto FindAssetPathPredicate = [&](const FString& InAssetPath) -> bool
			{
				return ObjectPath.StartsWith(InAssetPath, ESearchCase::IgnoreCase);
			};

			if (DialogueWavePathsToTest.ContainsByPredicate(FindAssetPathPredicate))
			{
				LoadedDialogueWaveAssets.Add(ObjectPath);
			}
		});

		ForEachObjectOfClass(USoundWave::StaticClass(), [&](UObject* InObject)
		{
			const FString ObjectPath = InObject->GetPathName();

			auto FindAssetPathPredicate = [&](const FString& InAssetPath) -> bool
			{
				return ObjectPath.StartsWith(InAssetPath, ESearchCase::IgnoreCase);
			};

			if (SoundWavePathsToTest.ContainsByPredicate(FindAssetPathPredicate))
			{
				LoadedSoundWaveAssets.Add(ObjectPath);
			}
		});
	}

	if (LoadedDialogueWaveAssets.Num() > 0 || LoadedSoundWaveAssets.Num() > 0)
	{
		FTextBuilder MsgBuilder;
		MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg", "The following audio assets have been loaded by the editor and may cause the dialogue import to fail as their files will be read-only."));
		MsgBuilder.AppendLine(FText::GetEmpty());
		MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg_Continue", "Do you want to continue?"));
				
		if (LoadedDialogueWaveAssets.Num() > 0)
		{
			MsgBuilder.AppendLine(FText::GetEmpty());
			MsgBuilder.AppendLine(LOCTEXT("Warning_LoadedAudioAssetsMsg_DialogueWaves", "Dialogue Waves:"));

			MsgBuilder.Indent();
			for (const FString& LoadedDialogueWaveAsset : LoadedDialogueWaveAssets)
			{
				MsgBuilder.AppendLine(LoadedDialogueWaveAsset);
			}
			MsgBuilder.Unindent();
		}

		if (LoadedSoundWaveAssets.Num() > 0)
//.........这里部分代码省略.........
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:101,代码来源:LocalizationCommandletTasks.cpp


注:本文中的TArray::ContainsByPredicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。