UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SequenceHistory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "HAL/UnrealMemory.h"
11
13template <SIZE_T HistorySize>
15{
16public:
17 typedef uint32 WordT;
18
19 static constexpr SIZE_T BitsPerWord = sizeof(WordT) * 8;
20 static constexpr SIZE_T WordCount = HistorySize / BitsPerWord;
22 static constexpr SIZE_T Size = HistorySize;
23
24 static_assert(HistorySize > 0, "HistorySize must be > 0");
25 static_assert(HistorySize % BitsPerWord == 0, "InMaxHistorySize must be a modulo of the wordsize");
26
27public:
29
30#if WITH_AUTOMATION_WORKER
32 WordT* Data() { return &Storage[0]; }
33 const WordT* Data() const { return &Storage[0]; }
34#endif
35
37 void Reset();
38
40 void AddDeliveryStatus(bool Delivered);
41
44
45 bool operator==(const TSequenceHistory& Other) const { return FMemory::Memcmp(Storage, Other.Storage, WordCount * sizeof (WordT)) == 0; }
46
47 bool operator!=(const TSequenceHistory& Other) const { return FMemory::Memcmp(Storage, Other.Storage, WordCount * sizeof (WordT)) != 0; }
48
50 void Write(FBitWriter& Writer, SIZE_T NumWords) const;
51
53 void Read(FBitReader& Reader, SIZE_T NumWords);
54
55private:
56 WordT Storage[WordCount];
57};
58
59template<SIZE_T HistorySize>
61
62template<SIZE_T HistorySize>
64
65template<SIZE_T HistorySize>
67
68template<SIZE_T HistorySize>
70
71template <SIZE_T HistorySize>
76
77#if WITH_AUTOMATION_WORKER
78template <SIZE_T HistorySize>
80{
81 Reset();
83 {
84 Storage[CurrentWordIt] = Value;
85 }
86}
87#endif
88
89template <SIZE_T HistorySize>
91{
92 FPlatformMemory::Memset(&Storage[0], 0, WordCount * sizeof(WordT));
93}
94
95template <SIZE_T HistorySize>
97{
98 WordT Carry = Delivered ? 1u : 0u;
99 const WordT ValueMask = 1u << (BitsPerWord - 1);
100
101 for (SIZE_T CurrentWordIt = 0; CurrentWordIt < WordCount; ++CurrentWordIt)
102 {
103 const WordT OldValue = Carry;
104
105 // carry over highest bit in each word to the next word
106 Carry = (Storage[CurrentWordIt] & ValueMask) >> (BitsPerWord - 1);
107 Storage[CurrentWordIt] = (Storage[CurrentWordIt] << 1u) | OldValue;
108 }
109}
110
111template <SIZE_T HistorySize>
113{
114 check(Index < Size);
115
116 const SIZE_T WordIndex = Index / BitsPerWord;
117 const WordT WordMask = (WordT(1) << (Index & (BitsPerWord - 1)));
118
119 return (Storage[WordIndex] & WordMask) != 0u;
120}
121
122template <SIZE_T HistorySize>
124{
125 NumWords = FPlatformMath::Min(NumWords, WordCount);
126 for (SIZE_T CurrentWordIt = 0; CurrentWordIt < NumWords; ++CurrentWordIt)
127 {
128 WordT temp = Storage[CurrentWordIt];
129 Writer << temp;
130 }
131}
132
133template <SIZE_T HistorySize>
135{
136 NumWords = FPlatformMath::Min(NumWords, WordCount);
137 for (SIZE_T CurrentWordIt = 0; CurrentWordIt < NumWords; ++CurrentWordIt)
138 {
139 Reader << Storage[CurrentWordIt];
140 }
141}
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition SequenceHistory.h:15
static constexpr SIZE_T BitsPerWord
Definition SequenceHistory.h:19
bool operator!=(const TSequenceHistory &Other) const
Definition SequenceHistory.h:47
bool operator==(const TSequenceHistory &Other) const
Definition SequenceHistory.h:45
static constexpr SIZE_T Size
Definition SequenceHistory.h:22
void AddDeliveryStatus(bool Delivered)
Definition SequenceHistory.h:96
static constexpr SIZE_T WordCount
Definition SequenceHistory.h:20
uint32 WordT
Definition SequenceHistory.h:17
void Write(FBitWriter &Writer, SIZE_T NumWords) const
Definition SequenceHistory.h:123
static constexpr SIZE_T MaxSizeInBits
Definition SequenceHistory.h:21
TSequenceHistory()
Definition SequenceHistory.h:72
bool IsDelivered(SIZE_T Index) const
Definition SequenceHistory.h:112
void Read(FBitReader &Reader, SIZE_T NumWords)
Definition SequenceHistory.h:134
void Reset()
Definition SequenceHistory.h:90
U16 Index
Definition radfft.cpp:71
Definition BitReader.h:25
Definition BitWriter.h:22
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition GenericPlatformMemory.h:581
static UE_FORCEINLINE_HINT int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
Definition UnrealMemory.h:114