FChunkedStructBuffer

Buffer where you can append heterogeneous structs, and iterate over them in order (no random access).

Choose your operating system:

Windows

macOS

Linux

References

Module

StructUtils

Header

/Engine/Plugins/Experimental/StructUtils/Source/StructUtils/Public/ChunkedStructBuffer.h

Include

#include "ChunkedStructBuffer.h"

Syntax

USTRUCT()
struct FChunkedStructBuffer

Remarks

Buffer where you can append heterogeneous structs, and iterate over them in order (no random access).

If you use move assign or Append(&&), make sure to call Compact() or you may end up with large free list.

Variables

Name Description

Protected variable

int32

 

ChunkSize

Number of items stored in the buffer

Protected variable

FChunkHeader &#...

 

First

Protected variable

FChunkHeader &#...

 

FreeList

Pointer to the last chunk in use

Protected variable

FChunkHeader &#...

 

Head

Pointer to the first chunk in use

Protected variable

int32

 

NumItems

Free list of unused chunks

Constructors

Name Description

Public function

FChunkedStructBuffer

(
    const int32 InChunkSize
)

Public function

FChunkedStructBuffer

(
    const FChunkedStructBuffer& Other
)

Public function

FChunkedStructBuffer

(
    FChunkedStructBuffer&& Other
)

Destructors

Name Description

Public function

~FChunkedStructBuffer()

Functions

Name Description

Public function

void

 

Add

(
    const FStructView Struct
)

Adds struct to the buffer based on ScriptStruct and pointer.

Public function

void

 

Add

(
    const T& InStruct
)

Add new struct in the buffer.

Public function

T &

 

Add_GetRef

(
    const T& InStruct
)

Add new struct in the buffer, and return reference to it.

Public function

void

 

AddStructReferencedObjects

(
    FReferenceCollector& Collector
)

Protected function

void

 

AllocateNewChunk()

Allocates a new chunk and makes it the head of the chunk list.

Protected function

uint8 *

 

AllocItem

(
    const UScriptStruct* InScriptS...
)

Allocates an item of specified type.

Public function

void

 

Append

(
    const FChunkedStructBuffer& Other
)

Public function

void

 

Append

(
    FChunkedStructBuffer&& Other
)

Public function

void

 

Clear()

Resets and clears all structs, and releases unused internal memory.

Public function

void

 

Compact()

Releases unused internal memory.

Public function

void

 

Emplace

(
    TArgs&&... InArgs
)

Emplaces struct in the buffer.

Public function

T &

 

Emplace_GetRef

(
    TArgs&&... InArgs
)

Emplaces struct in the buffer, and returns reference to it.

Public function Const

void

 

ForEach

(
    TFunc&& Function
)

Iterates over all structs of specified type T and calls Function on each item.

Public function Const

void

 

ForEach

(
    TFunc&& Function
)

Iterates over all structs and calls Function on each item

Public function Const

void

 

ForEachFiltered

(
    TArrayView< const UScriptStruct...,
    TFunc&& Function
)

Iterates over all structs of specified types and calls Function on each item

Public function Const

int32

 

GetChunkSize()

Public function Const

int32

 

GetNumFreeChunks()

Public function Const

int32

 

GetNumUsedChunks()

Public function Const

void

 

GetScriptStructs

(
    TArray< const UScriptStruct* >...
)

Returns struct types in the buffer

Public function Const

bool

 

IsEmpty()

Public function Const

int32

 

Num()

Public function

void

 

Reset()

Resets and clears all structs, keeps internal memory.

Operators

Name Description

Public function

FChunkedStru...

 

operator=

(
    const FChunkedStructBuffer& Other
)

Public function

FChunkedStru...

 

operator=

(
    FChunkedStructBuffer&& Other
)

Classes

Name

Description

Protected struct

FChunkHeader

Header for a chunk of items.

Protected struct

FItemHeader

Header for each item in a chunk. Allocated before the item in tge chunk memory.

Constants

Name

Description

DefaultChunkSize

MaxScriptStructsPerChunk

Number of unique struct types that can be stored per chunk.