Object TPointerView
Unit
Declaration
type generic TPointerView<TElement> = object(TObject)
Description
An array view representing a slice (subsequence) of an array.
The view is read-only and can only shrink. Methods with pointer arguments are safe, such that pointers outside the view either yield an empty view or keep the view unchanged.
Methods Move* remove elements from the beginning, methods Cut* remove elements from the end, i.e.:
|----------leftOf(x)---------||--------------------rightWith(x)-----------------|
ppppppppppppppppppppppppppppppxxxxxxxxxxxxxxxxxxxxxxsssssssssssssssssssssssssssss <- the initial array view
|-------------------leftWith(x)--------------------||---------rightOf(x)--------|
Methods View* return a new view. To and From are inclusive, while Until and After are exclusive, i.e.:
|--------viewLeftOf(x)-------||------------------viewRightWith(x)---------------|
ppppppppppppppppppppppppppppppxxxxxxxxxxxxxxxxxxxxxxsssssssssssssssssssssssssssss <- the initial array view
|-------------------viewLeftWith(x)----------------||---------rightOf(x)--------|
To avoid confusion, whether indices should be 0-based or 1-based, signed or unsigned, most methods of this view are specified without refering to indices. Rather they use pointers or an amount of elements. E.g. rather than getting a slice of all elements after index k, you use moveBy to remove the first k elements.
Hierarchy
- TObject
- TPointerView
Overview
Nested Types
![]() |
PElement = ˆTElement; |
![]() |
TElementToString = function (const e: TElement): string; |
Fields
![]() |
data: pelement; |
![]() |
dataend: pelement; |
Methods
![]() |
procedure init(firstelement: PElement; length: sizeint); |
![]() |
procedure init(firstelement, behindlastelement: PElement); |
![]() |
procedure init(const a: array of TElement); |
![]() |
function length: SizeInt; |
![]() |
function isEmpty: boolean; inline; |
![]() |
function isEqual(const other: TPointerView): boolean; |
![]() |
function isEqual(const other: array of telement): boolean; |
![]() |
function isInBounds(target: PElement): boolean; inline; |
![]() |
function isOnBounds(target: PElement): boolean; inline; |
![]() |
function getEnumerator: TPointerViewEnumerator; inline; |
![]() |
function rightOfFirst(delta: SizeUInt): boolean; |
![]() |
function rightWithLast(alength: SizeUInt): boolean; |
![]() |
procedure rightWith(target: PElement); |
![]() |
procedure rightOf(target: PElement); |
![]() |
function leftOfLast(delta: SizeUInt): boolean; |
![]() |
function leftWithFirst(alength: SizeUInt): boolean; |
![]() |
procedure leftOf(target: PElement); |
![]() |
procedure leftWith(target: PElement); |
![]() |
function count(const e: TElement): SizeUInt; |
![]() |
function joinToString(elementMap: TElementToString; const sep: string): string; |
![]() |
function viewLeftWith(newLast: PElement): TPointerView; |
![]() |
function viewLeftOf(newEnd: PElement): TPointerView; |
![]() |
function viewRightWith(newStart: PElement): TPointerView; |
![]() |
function viewRightOf(newStartSkip: PElement): TPointerView; |
Description
Nested Types
![]() |
PElement = ˆTElement; |
![]() |
TElementToString = function (const e: TElement): string; |
Fields
![]() |
data: pelement; |
![]() |
dataend: pelement; |
Methods
![]() |
procedure init(firstelement: PElement; length: sizeint); |
|
Creates a view starting with an element of certain length. | |
![]() |
procedure init(firstelement, behindlastelement: PElement); |
|
Creates a view starting with an element (inclusive) until another element (exclusive). | |
![]() |
procedure init(const a: array of TElement); |
|
Creates a view for a (dynamic) array. | |
![]() |
function length: SizeInt; |
|
Number of elements in the view. | |
![]() |
function isEmpty: boolean; inline; |
|
Tests whether the length zero. | |
![]() |
function isEqual(const other: TPointerView): boolean; |
|
Tests whether this view is equal to another view (same length and elements) (currently undefined if element is a string). | |
![]() |
function isEqual(const other: array of telement): boolean; |
|
Tests whether this view is equal to another view (same length and elements) (currently undefined if element is a string). | |
![]() |
function isInBounds(target: PElement): boolean; inline; |
|
Tests whether an element is in the view (0 <= index < length). | |
![]() |
function isOnBounds(target: PElement): boolean; inline; |
|
Tests whether an element is on the view (0 <= index <= length). | |
![]() |
function getEnumerator: TPointerViewEnumerator; inline; |
|
Enumerates all elements, copying each. | |
![]() |
function rightOfFirst(delta: SizeUInt): boolean; |
|
Removes delta many elements from the beginning. | |
![]() |
function rightWithLast(alength: SizeUInt): boolean; |
|
Take the last length elements | |
![]() |
procedure rightWith(target: PElement); |
|
Removes all elements before the target element. | |
![]() |
procedure rightOf(target: PElement); |
|
Removes all elements before the target element and the target element. | |
![]() |
function leftOfLast(delta: SizeUInt): boolean; |
|
Removes delta many elements from the end. | |
![]() |
function leftWithFirst(alength: SizeUInt): boolean; |
![]() |
procedure leftOf(target: PElement); |
|
Removes all elements after the target element and the target element. | |
![]() |
procedure leftWith(target: PElement); |
|
Removes all elements after the target element. | |
![]() |
function count(const e: TElement): SizeUInt; |
|
| |
![]() |
function joinToString(elementMap: TElementToString; const sep: string): string; |
![]() |
function viewLeftWith(newLast: PElement): TPointerView; |
|
copy and leftWith. | |
![]() |
function viewLeftOf(newEnd: PElement): TPointerView; |
|
copy and leftOf. | |
![]() |
function viewRightWith(newStart: PElement): TPointerView; |
|
copy and rightWith. | |
![]() |
function viewRightOf(newStartSkip: PElement): TPointerView; |
|
copy and rightOf. | |
Generated by PasDoc 0.16.0.

