[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

LVariableArray



Overview:

LVariableArray is a PowerPlant class that is similar to LArray, but allows you to store data of differing element sizes.

Methods :

The methods in this class are:

 

LVariableArray()  
~LVariableArray()  
AdjustAllocation()  
AdjustStorage()  
AssignItemsAt()  
GetItemOffset()  
GetItemPtr()  
GetItemSize()  
GetOffsetsHandle()  
GrabItemRangeSize()  
GrabItemSize()  
InternalAdjustAllocation()  
InternalCopyItem()  
PokeItem()  
ShiftItems()  
Sort()  
StoreNewItems()  
 

Data Members:

The data members in this class are:

 

mItemOffsetsH  
mItemsAllocated  

Operation:

This class overrides several member functions of LArray to implement data storage and retrieval in a situation where array elements vary in size.

The public interface and usage is mostly identical to that of LArray.

Source files:

(Array Classes)

LVariableArray.h

LVariableArray.cp

Ancestors:

LArray

See Also:

LArrayIterator

LComparator

LLockedArrayIterator

LVariableArray()

Purpose:

The constructor creates objects from the passed-in parameters.

Access:

Public

Prototype:

LVariableArray( LComparator *inComparator,
Boolean inKeepSorted );

LVariableArray( Handle inItemsHandle,
ArrayOffsetH inOffsetsHandle,
LComparator *inComparator,
Boolean inIsSorted,
Boolean inKeepSorted );
Parameters:

The parameters for these constructors are:

 

LComparator*  
inComparator  
The pointer to the comparator object to use.  
Boolean  
inKeepSorted  
Whether to keep the array sorted or not.  
Handle  
inItemsHandle  
A handle to the items to put into the array.  
ArrayOffsetH  
inOffsetsHandle  
An offset. It is assumed that the number of items for the array is the same as the number of offsets in the handle.  
Boolean  
inIsSorted  
Whether the elements are sorted or not.  

~LVariableArray()

Purpose:

The destructor destroys the object.

Access:

Public

Prototype:

virtual ~LVariableArray();

AdjustAllocation()

Purpose:

Adjust the size of the Handle used to store array items. This is an override of AdjustAllocation() in LArray.

AdjustStorage()

Purpose:

Called internally when the number of bytes used by Items in the array changes. This is an override of AdjustStorage() in LArray.

AssignItemsAt()

Purpose:

Assign the same value to items starting at the specified index. This is an override of AdjustStorage() in LArray.

GetItemOffset()

Purpose:

This method returns the offset into the array for a given item.

Access:

Protected

Prototype:

UInt32 GetItemOffset( ArrayIndexT inAtIndex);
Parameters:

This method has the following parameter:

 

ArrayIndexT  
inAtIndex  
The index to calculate an offset for.  

Return:

UInt32 containing the offset.

GetItemPtr()

Purpose:

Return a pointer to the start of an item's data within the internal storage Handle. This method performs no error checking on the index.

Access:

Virtual, Public

Prototype:

virtual void* GetItemPtr(ArrayIndexT inIndex) 
const;
Parameters:

This method has the following parameter:

 

ArrayIndexT  
inIndex  
The index for the item.  

Return:

The pointer to the array item.

Remarks:

WARNING: Unless you have called Lock(), the returned pointer points to data within a relocatable Handle block.

GetItemSize()

Purpose:

Return the size in bytes of an item in the array.

Access:

Virtual, Public

Prototype:

virtual UInt32 GetItemSize(
ArrayIndexT inIndex) const;
Parameters:

This method has the following parameter:

 

ArrayIndexT  
inIndex  
The index to get an item.  

Return:

UInt32 containing the size in bytes of an item.

GetOffsetsHandle()

Purpose:

Return Handle used to store offsets to the data for array items. This is an accessor method for mItemOffsetsH.

Access:

Public

Prototype:

Handle GetOffsetsHandle() const;
Parameters:

None

Return:

The handle used to store offsets (mItemOffsetsH).

Remarks:

GrabItemRangeSize()

Purpose:

Return the size in bytes of the items from inStartIndex to inEndIndex, inclusive. This is an override of GrabItemRangeSize() in LArray.

GrabItemSize()

Purpose:

Return the size in bytes of the specified item. This method is the same as GetItemSize() except it doesn't validate inIndex.This is an override of GrabItemSize() in LArray.

InternalAdjustAllocation()

Purpose:

Called internally to change the size of the storage used. This is an override of InternalAdjustAllocation() in LArray.

InternalCopyItem()

Purpose:

Set the item at inDestIndex to a copy of the item at inSourceIndex. This is an override of InternalCopyItem() in LArray.

PokeItem()

Purpose:

Store data for the item at the specified index. This is an override of PokeItem() in LArray.

ShiftItems()

Purpose:

Moves items within the Handle used for internal storage. This is an override of ShiftItems() in LArray.

Sort()

Purpose:

Sort items in the array. This is an override of Sort() in LArray.

StoreNewItems()

Purpose:

Store values within the internal storage Handle. Items all have the same value, and space must already have been allocated for them. This is an override of StoreNewItems() in LArray.

mItemOffsetsH

Purpose:

This stores the handle for the offsets.

Access:

Protected

Prototype:

ArrayOffsetH mItemOffsetsH;

mItemsAllocated

Purpose:

This stores the items allocated information.

Access:

Protected

Prototype:

UInt32 mItemsAllocated;

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000