Skip to content

Instantly share code, notes, and snippets.

@tenpn
Created September 1, 2023 11:39
Show Gist options
  • Save tenpn/d67bc33bc04c5165a49afa14555637b8 to your computer and use it in GitHub Desktop.
Save tenpn/d67bc33bc04c5165a49afa14555637b8 to your computer and use it in GitHub Desktop.
struct FWidget
{
FWidget() : Name() {}
FWidget(FString Name) : Name(Name) {}
FWidget(FWidget Other) : Name(Other.Name) {}
void ProcessIntensity(float Intensity) { /** **/ }
FString Name;
}
void ProcessWidgets(const TArray<FWidget> WidgetsToProcess, float Intensity)
{
for(auto Widget : WidgetsToProcess)
{
Widget.ProcessIntensity(Intensity);
}
}
TArray<FWidget> CollectWidgets()
{
TArray<FWidget> Widgets;
// collect
return Widgets;
}
// returns default Widget if can't be found
FWidget FindWidget(const TArray<FWidget> WidgetsToSearch, FString Name)
{
for(const auto Widget : WidgetsToSearch)
{
if (Widget.Name == Name)
{
return Widget;
}
}
return FWidget();
}
void Main()
{
const TArray<FWidget> Widgets = CollectWidgets();
ProcessWidgets(Widgets, 99.9f);
const FWidget Found = FindWidget(Widgets, TEXT("Find me"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment