UKismetMathLibrary::MaxOfByteArray
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureUFUNCTION
Description
Finds the maximum byte (uint8) in an array and its index. Returns MaxValue=0 and IndexOfMaxValue=-1 on an empty array.
Caveats & Gotchas
- • In Blueprint, byte arrays map to Enum arrays — this function is most commonly used with byte-enum values where you want the numerically highest enum member.
- • An empty array returns MaxValue of 0 and index -1; since 0 is a valid byte value, always verify IndexOfMaxValue before using MaxValue.
Signature
static ENGINE_API void MaxOfByteArray(const TArray<uint8>& ByteArray, int32& IndexOfMaxValue, uint8& MaxValue); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ByteArray | const TArray<uint8>& | The array to search. | — |
| IndexOfMaxValue | int32& | Output: index of the maximum value. -1 if array is empty. | — |
| MaxValue | uint8& | Output: the maximum byte value found. 0 if array is empty. | — |
Return Type
void Example
Find the highest priority byte flag C++
TArray<uint8> Priorities = { 2, 5, 1, 5, 3 };
int32 Index;
uint8 Max;
UKismetMathLibrary::MaxOfByteArray(Priorities, Index, Max);
// Max == 5, Index == 1 Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?