Skip to content

TSlice<T>

A class representing a slice of contiguous elements of type T.

A Slice provides a view into a contiguous sequence of elements without owning the memory. It allows for efficient access and iteration over a portion of a contiguous data structure.

Definition

Unit: Neslib.Iceoryx2.Containers

type TSlice<T> = record ... end;

Type Parameters

T:

Nested Types

Name Description
P

Properties

Name Description
Data Returns a pointer to the underlying data of the slice.
Elements Accesses the element at the specified index.
NumberOfBytes Returns the total number of bytes occupied by the slice, rounded up to the nearest alignment boundary.
NumberOfElements Returns the number of elements in the slice.
Refs Returns a reference to the element at the specified index.

Constructors

Name Description
Create Constructs a Slice object.

Methods

Name Description
Init Constructs a Slice object.

Property Descriptions

Data

Returns a pointer to the underlying data of the slice.

property Data: P read FData

Type: P


Elements

Accesses the element at the specified index.

property Elements[const AIndex: Int64]: T read GetElement write SetElement; default

Type: T

Remarks

Setting the element is only allowed for mutable slices. This is checked with an assertion.


NumberOfBytes

Returns the total number of bytes occupied by the slice, rounded up to the nearest alignment boundary.

property NumberOfBytes: Int64 read GetNumberOfBytes

Type: Int64


NumberOfElements

Returns the number of elements in the slice.

property NumberOfElements: Int64 read FNumberOfElements

Type: Int64


Refs

Returns a reference to the element at the specified index.

property Refs[const AIndex: Int64]: P read GetRef

Type: P

Remarks

When the slice is immutable, you should not change the value of the returned reference. Doing so results in undefined behavior or access violations.


Constructor Descriptions

Create

Constructs a Slice object.

constructor Create(const AData: Pointer; const ANumberOfElements: Int64; const AIsMutable: Boolean)

Parameters

AData: Pointer : Pointer to the beginning of the data.

ANumberOfElements: Int64 : The number of elements in the slice..

AIsMutable: Boolean : Whether the slice is mutable, meaning whether the elements in the slice can be changed. When False, changing elements in the slice raises an assertion.


Method Descriptions

Init(Pointer, Int64, Boolean)

Constructs a Slice object.

procedure Init(const AData: Pointer; const ANumberOfElements: Int64; const AIsMutable: Boolean); inline

Parameters

AData: Pointer : Pointer to the beginning of the data.

ANumberOfElements: Int64 : The number of elements in the slice..

AIsMutable: Boolean : Whether the slice is mutable, meaning whether the elements in the slice can be changed. When False, changing elements in the slice raises an assertion.