Class APointerVector

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type APointerVector = class(AVector)

Description

This class represents a vector of pointers. It is unlikely that you will directly instantiate this class, since its functionality is fairly basic. Instead, you will either derive a class from it that implements the higher-level functionality required, or you can use an instance of AnObjectVector.

The size of the elements managed by this array will depend on the target platform for which the code is compiled. On 32-bit systems, pointers generally occupy four bytes, whereas on 64-bit systems they take up eight bytes.

It is worth noting that, although this class is capable of writing its data to a stream, and of retrieving it therefrom, it is unlikely that such behavior will be of much use because pointer values read from a stream are likely to be invalid unless some method is devised to apply a fixup to each pointer value or to ensure that the items referenced will always exist at the same location in memory.

Hierarchy

Overview

Methods

Public constructor ofLength(const elementCount: TCensus); reintroduce; virtual;
Public procedure pushReference(const source: pointer); virtual;
Public procedure pushReferenceTo(var source); virtual;
Public function appendReference(const source: pointer): TNodeAbsoluteIndex; virtual;
Public function appendReferenceTo(var source): TNodeAbsoluteIndex; virtual;
Public function popReference: pointer; virtual;
Public procedure insertReferenceAt(const thisIndex: TNodeAbsoluteIndex; const source: pointer); virtual;
Public procedure insertReferenceTo(var source; const thisIndex: TNodeAbsoluteIndex); virtual;
Public function removeReferenceAt(const thisIndex: TNodeAbsoluteIndex): pointer; virtual;
Public procedure deleteReferenceAt(const thisIndex: TNodeAbsoluteIndex); virtual;
Public function referenceAt(const thisIndex: TNodeAbsoluteIndex): pointer; virtual;
Public function setReferenceAt(const thisIndex: TNodeAbsoluteIndex; const source: pointer): pointer; virtual;
Public function setReferenceTo(var source; const thisIndex: TNodeAbsoluteIndex): pointer; virtual;

Description

Methods

Public constructor ofLength(const elementCount: TCensus); reintroduce; virtual;

Construct a new managed array of pointers that will initially contain the specified number of elements.

The elements are zero-filled by this routine.

This method calls AVector.ofLength and so may raise an exception if a block of memory large enough to contain the requested number of elements could not be allocated.

Exceptions raised
AVectorAllocationError
if a block of memory large enough to hold elementCount could not be allocated.
Public procedure pushReference(const source: pointer); virtual;

Push a pointer onto the end of the array.

This method calls AVector.pushElement, which will grow the array as needed.

Public procedure pushReferenceTo(var source); virtual;

Push a pointer to the given item onto the end of the array.

This method creates a pointer to source and pushes it onto the array.

This method calls AVector.pushElement, which will grow the array as needed.

Public function appendReference(const source: pointer): TNodeAbsoluteIndex; virtual;

Add a pointer to the end of the array and return the index assigned to it.

This method pushes the specified pointer onto the end of the array and returns its index. This index is NOT guaranteed to remain static; if items are added to or removed from the array at positions that come before the new item, then the new item's index will change.

This method calls AVector.appendElement.

Public function appendReferenceTo(var source): TNodeAbsoluteIndex; virtual;

Add a pointer to the given item to the end of the array and return the index assigned to it.

This method pushes a pointer to source onto the end of the array and returns its index. This index is NOT guaranteed to remain static; if items are added to or removed from the array at positions that come before the new item, then the new item's index will change.

This method calls AVector.appendElement.

Public function popReference: pointer; virtual;

Pop the last pointer from the end of the array.

This method retrieves the last element in the array and returns it to the caller. If the array has no elements, then it returns Nil.

This method calls AVector.popElement.

Public procedure insertReferenceAt(const thisIndex: TNodeAbsoluteIndex; const source: pointer); virtual;

Insert the specified pointer at the specified index in the array.

If an item already exists at thisIndex, then it is "moved right": its index will increase by one, as will the indices of all items that come after it. If thisIndex specifies a value that is greater than AVector.length, then the source pointer is simply added to the end of the array in much the same way as if APointerVector.pushReference were called.

This method calls AVector.insertElementAt.

Public procedure insertReferenceTo(var source; const thisIndex: TNodeAbsoluteIndex); virtual;

Insert a pointer to the specified item at the specified index in the array.

If an item already exists thisIndex, then it is "moved right": its index will increase by one, as will the indices of all items that come after it. If thisIndex specifies a value that is greater than AVector.length, then the pointer to source is simply placed at the end of the array in much the same way as if APointerVector.pushReferenceTo were called.

This method calls AVector.insertElementAt.

Public function removeReferenceAt(const thisIndex: TNodeAbsoluteIndex): pointer; virtual;

Remove and return the pointer at the specified index.

This method removed the pointer at thisIndex and returns it to the caller. Any items in the array which have higher indices than thisIndex are "moved left": their indices decrease by one. If thisIndex specifies a value that is greater than AVector.length, then this method simply returns the last pointer in the array in much the same way as if APointerVector.popReference were called.

This method calls AVector.removeElementAt.

Public procedure deleteReferenceAt(const thisIndex: TNodeAbsoluteIndex); virtual;

Delete the pointer at the specified index.

This method deletes the pointer at thisIndex. Any items in the array which have higher indices than thisIndex are "moved left": their indices decrease by one. If thisIndex specifies a value that is greater than AVector.length, then this method removes the last pointer in the array.

Note that this method does not free the item referenced by the pointer which is discarded; it is the caller's responsibility to ensure that this happens, if necessary, in order to avoid memory leaks.

This method calls AVector.deleteElementAt.

Public function referenceAt(const thisIndex: TNodeAbsoluteIndex): pointer; virtual;

Retrieve the pointer at the specified index.

This method retrieves the pointer at thisIndex. If thisIndex specifies a value that is greater than AVector.length, then this method retrieves the last pointer in the array.

The caller is free to manipulate the pointer as desired.

This method calls AVector.getElementAt.

Public function setReferenceAt(const thisIndex: TNodeAbsoluteIndex; const source: pointer): pointer; virtual;

Set the pointer at the specified index.

This method sets the pointer at thisIndex. If thisIndex specifies a value that is greater than AVector.length, then this method sets the last pointer in the array.

This method calls AVector.setElementAt.

Returns

The previous pointer at the specified index, if any.

Public function setReferenceTo(var source; const thisIndex: TNodeAbsoluteIndex): pointer; virtual;

Set the pointer at the specified index to point to the specified item.

This method obtains a pointer to source and sets the pointer at thisIndex to that value. If thisIndex specifies a value that is greater than AVector.length, then this method sets the last pointer in the array.

Returns

The previous pointer at the specified index, if any.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18