# class ValueArray

ValueArray adds methods to arrays to generically add, set and get tuples, through real values.

See also: Array

# Properties

Property Description
AlternativeName A string that can be used to identify the array in collections.
ItemCount The number of individual items in the array. Warning! Do not confuse this count with the count of tuples, they are only the same if TupleSize is equal to 1, i.e. when the tuples are exactly one component each. Also note that the item count should be a multiple of TupleSize. Note that the total number of items cannotexceed INT_MAX.
TupleCount The tuple count, meaning how many tuples are in the array. If resized to larger array, the new tuples will not be set to anything.
TupleSize The tuple size, meaning how many items of the underlying data type is in a tuple. The tuple size must be set before the array is populated.

# Methods

Method Description
AppendArray Appends an array to this array. The array must be a descendant of ValueArray. For best performance, append arrays of the same basic type.
Clear Clears the array and sets the tuple count to 0. Tuple size and name remains the same though.
CompareTuples CompareTuples compares a tuple in this array with a tuple in another array. Returns 0 if the tuples are identical, 1 if an element in this array tuple in ascending order is larger and -1 if smaller.
CopyRange CopyRange copies a range of tuples from a source array into this array. The arrays must have the same tuple size and base type. This array must be resized to hold the tuples before copying. The basetypes are listed in EBaseTypes.
CopyTuple CopyTuple copies one tuple in a source array to a tuple in this array. Both the dest_id and the source_id must exist in the arrays. This array can be used as the source array to copy within the array.
DeepCopy Copies data from another array. The arrays must have the same underlying data types.
ExtractTuples Extracts tuples from the array. Note that the destination array must have the same classtype and have the same tuple size as the source array. (If both arrays are decendants of ValueArray, they can be of different types, but the conversion is slow).
GetBaseType Returns the id of the basic type that the array is based on The ids are listed in the BaseTypes enumeration.
GetClass Get the name of the ValueArray class.
GetMaxItemId Returns the id of the last item that is in the array. The id returned is equal to (ItemCount - 1). Warning! Do not confuse this id with the id of a tuple, they are only the same if TupleSize is equal to one, i.e. when the tuples are exactly one component each.
GetMaxTupleId Returns the id of the tuple last in the list. If the array is empty, the value is unspecified. Note: GetMaxTupleId() always returns (GetTupleCount()-1) as a signed id.
GetRealItem GetRealItem() retrieves the item at position id. The id is the id of the item, not the tuple the item belongs to. GetRealItem() converts the value from the actual underlying data type to a real.
IndexedCopy Copies tuples from a source array through an id table. The id table dictates the order in which the tuples are to be copied to this array. E.g. If the first item in the id table has the value 14, then the tuple with id 14 in the source array will be copied to the first tuple in this array. Note: All ids in the id table must be valid ids of tuples in the source array. The id table is assumed to have a tuple size of 1. The source array and this array must have the same underlying data type, and have the same tuple size. The array must be large enough to hold the copied data.
IsA Returns true if ValueArray is a or is a descendant of the class named as the type parameter.
IsEmpty Returns true if the list is empty.
IsNull Returns true if the ValueArray object is invalid.
NewCopy Creates a new array with the same underlying data type, size and tuple settings as this array. To also copy the actual data, set copy_data to true.
NewPackedCopy Like NewCopy, NewPackedCopy creates an array with the same underlying data and tuple settings as the source array. However, NewPackedCopy only copies unique tuples, and if the index_array parameter is set, this index array will contain the same number of tuples as the source array, and with the ids of a specific tuples within the new copy of the array.
SetRealItem SetRealItem() sets the item at position id. The id is the id of the item, not the tuple the item belongs to. SetRealItem() converts the value from real to the actual underlying data type.

# Static methods

Method Description
IsClassA Returns true if the class is a or is a descendant of the class named as the type parameter.
SafeCast SafeCast makes sure the input object is of a class that can be cast into spValueArray, and if this is the case, returns the object cast into spValueArray.

# Properties details

# AlternativeName

A string that can be used to identify the array in collections.

# Syntax

// Setter
void SetAlternativeName( const char * value );

// Getter
spString GetAlternativeName();

# SetAlternativeName parameters

Type Name Min Max Description
const char * value The new alternative name.

# GetAlternativeName return value

Type: spString

# ItemCount

The number of individual items in the array. Warning! Do not confuse this count with the count of tuples, they are only the same if TupleSize is equal to 1, i.e. when the tuples are exactly one component each. Also note that the item count should be a multiple of TupleSize. Note that the total number of items cannotexceed INT_MAX.

# Syntax

// Setter
void SetItemCount( unsigned int value );

// Getter
unsigned int GetItemCount();

# SetItemCount parameters

Type Name Min Max Description
unsigned int value 1 INT_MAX The desired item count.

# GetItemCount return value

Type: unsigned int

Default: 1

# TupleCount

The tuple count, meaning how many tuples are in the array. If resized to larger array, the new tuples will not be set to anything.

# Syntax

// Setter
void SetTupleCount( unsigned int value );

// Getter
unsigned int GetTupleCount();

# SetTupleCount parameters

Type Name Min Max Description
unsigned int value 1 INT_MAX The desired tuple count.

# GetTupleCount return value

Type: unsigned int

Default: 1

# TupleSize

The tuple size, meaning how many items of the underlying data type is in a tuple. The tuple size must be set before the array is populated.

# Syntax

// Setter
void SetTupleSize( unsigned int value );

// Getter
unsigned int GetTupleSize();

# SetTupleSize parameters

Type Name Min Max Description
unsigned int value 1 1024 The desired tuple size.

# GetTupleSize return value

Type: unsigned int

Default: 1

# Methods details

# AppendArray

Appends an array to this array. The array must be a descendant of ValueArray. For best performance, append arrays of the same basic type.

# Syntax

void AppendArray( spArray source );

# Parameters

Type Name Min Max Description
Array source The array to append to this array.

# Clear

Clears the array and sets the tuple count to 0. Tuple size and name remains the same though.

# Syntax

void Clear();

# Parameters

Clear takes no parameters.

# CompareTuples

CompareTuples compares a tuple in this array with a tuple in another array. Returns 0 if the tuples are identical, 1 if an element in this array tuple in ascending order is larger and -1 if smaller.

# Syntax

int CompareTuples( spArray otherArray , rid tuple_id , rid other_tuple_id );

# Parameters

Type Name Min Max Description
Array otherArray The other array to compare with.
rid tuple_id 0 MaxTupleId The tuple from this array to use for comparison.
rid other_tuple_id 0 The tuple from the other array to use for comparison.

# Return value

Type: int

# CopyRange

CopyRange copies a range of tuples from a source array into this array. The arrays must have the same tuple size and base type. This array must be resized to hold the tuples before copying. The basetypes are listed in EBaseTypes.

# Syntax

void CopyRange( spArray source_array , rid start_dest_id , rid start_src_id , unsigned int count );

# Parameters

Type Name Min Max Description
Array source_array The source array to copy from.
rid start_dest_id The first destination tuple id.
rid start_src_id The first source tuple id.
unsigned int count The number of tuples to copy.

# CopyTuple

CopyTuple copies one tuple in a source array to a tuple in this array. Both the dest_id and the source_id must exist in the arrays. This array can be used as the source array to copy within the array.

# Syntax

void CopyTuple( spArray sourceArray , rid dest_id , rid src_id );

# Parameters

Type Name Min Max Description
Array sourceArray The source array to copy from.
rid dest_id 0 MaxTupleId The tuple index in this array to copy into.
rid src_id 0 The tuple index in the source array to copy from.

# DeepCopy

Copies data from another array. The arrays must have the same underlying data types.

# Syntax

void DeepCopy( spArray source );

# Parameters

Type Name Min Max Description
Array source The source array to copy from.

# ExtractTuples

Extracts tuples from the array. Note that the destination array must have the same classtype and have the same tuple size as the source array. (If both arrays are decendants of ValueArray, they can be of different types, but the conversion is slow).

# Syntax

void ExtractTuples( spArray dest , rid start , unsigned int count );

# Parameters

Type Name Min Max Description
Array dest The array that will store the extracted tuples.
rid start 0 MaxTupleId This array tuple index where the extraction starts.
unsigned int count INT_MAX The number of tuples to extract.

# GetBaseType

Returns the id of the basic type that the array is based on The ids are listed in the BaseTypes enumeration.

# Syntax

Simplygon::EBaseTypes GetBaseType();

# Parameters

GetBaseType takes no parameters.

# Return value

Type: EBaseTypes

Key Value Comment
TYPES_ID_VOID 0
TYPES_ID_BOOL 1
TYPES_ID_CHAR 2
TYPES_ID_UCHAR 3
TYPES_ID_SHORT 4
TYPES_ID_USHORT 5
TYPES_ID_INT 6
TYPES_ID_UINT 7
TYPES_ID_LONG 8
TYPES_ID_ULONG 9
TYPES_ID_FLOAT 10
TYPES_ID_DOUBLE 11
TYPES_ID_REAL 12
TYPES_ID_RID 13
TYPES_ID_RCHAR 14
TYPES_ID_RHANDLE 15
TYPES_ID_STRING 16
TYPES_ID_OBJECT 17

# GetClass

Get the name of the ValueArray class.

# Syntax

spString GetClass();

# Parameters

GetClass takes no parameters.

# Return value

Type: spString

# GetMaxItemId

Returns the id of the last item that is in the array. The id returned is equal to (ItemCount - 1). Warning! Do not confuse this id with the id of a tuple, they are only the same if TupleSize is equal to one, i.e. when the tuples are exactly one component each.

# Syntax

rid GetMaxItemId();

# Parameters

GetMaxItemId takes no parameters.

# Return value

Type: rid

# GetMaxTupleId

Returns the id of the tuple last in the list. If the array is empty, the value is unspecified. Note: GetMaxTupleId() always returns (GetTupleCount()-1) as a signed id.

# Syntax

rid GetMaxTupleId();

# Parameters

GetMaxTupleId takes no parameters.

# Return value

Type: rid

# GetRealItem

GetRealItem() retrieves the item at position id. The id is the id of the item, not the tuple the item belongs to. GetRealItem() converts the value from the actual underlying data type to a real.

# Syntax

real GetRealItem( rid id );

# Parameters

Type Name Min Max Description
rid id 0 MaxItemId The item to get.

# Return value

Type: real

# IndexedCopy

Copies tuples from a source array through an id table. The id table dictates the order in which the tuples are to be copied to this array. E.g. If the first item in the id table has the value 14, then the tuple with id 14 in the source array will be copied to the first tuple in this array. Note: All ids in the id table must be valid ids of tuples in the source array. The id table is assumed to have a tuple size of 1. The source array and this array must have the same underlying data type, and have the same tuple size. The array must be large enough to hold the copied data.

# Syntax

void IndexedCopy( spArray source , spRidArray idtable , rid startId );

# Parameters

Type Name Min Max Description
Array source The array from which to copy tuples.
RidArray idtable The array with the tuple indices to copy.
rid startId The first tuple that will receive the copied values.

# IsA

Returns true if ValueArray is a or is a descendant of the class named as the type parameter.

# Syntax

bool IsA( const char * type );

# Parameters

Type Name Min Max Description
const char * type Name of the class to check if ValueArray is, or is a descendant of.

# Return value

Type: bool

# IsEmpty

Returns true if the list is empty.

# Syntax

bool IsEmpty();

# Parameters

IsEmpty takes no parameters.

# Return value

Type: bool

# IsNull

Returns true if the ValueArray object is invalid.

# Syntax

bool IsNull();

# Parameters

IsNull takes no parameters.

# Return value

Type: bool

# NewCopy

Creates a new array with the same underlying data type, size and tuple settings as this array. To also copy the actual data, set copy_data to true.

# Syntax

spArray NewCopy( bool copy_data );

# Parameters

Type Name Min Max Description
bool copy_data If set, duplicate all the data. If cleared, return an empty array of the same type.

# Return value

Type: Array

# NewPackedCopy

Like NewCopy, NewPackedCopy creates an array with the same underlying data and tuple settings as the source array. However, NewPackedCopy only copies unique tuples, and if the index_array parameter is set, this index array will contain the same number of tuples as the source array, and with the ids of a specific tuples within the new copy of the array.

# Syntax

spArray NewPackedCopy( spRidArray index_array );

# Parameters

Type Name Min Max Description
RidArray index_array The optional array that will receive the indices of the remapped tuples.

# Return value

Type: Array

# SetRealItem

SetRealItem() sets the item at position id. The id is the id of the item, not the tuple the item belongs to. SetRealItem() converts the value from real to the actual underlying data type.

# Syntax

void SetRealItem( rid id , real value );

# Parameters

Type Name Min Max Description
rid id 0 MaxItemId The item to set.
real value The real value to set the item to.

# Static methods details

# IsClassA

Returns true if the class is a or is a descendant of the class named as the type parameter.

# Syntax

static bool IsClassA( const char * type );

# Parameters

Type Name Min Max Description
const char * type Name of the class to check if the class is, or is a descendant of.

# Return value

Type: bool

# SafeCast

SafeCast makes sure the input object is of a class that can be cast into spValueArray, and if this is the case, returns the object cast into spValueArray.

# Syntax

static spValueArray SafeCast( spObject object );

# Parameters

Type Name Min Max Description
Object object Object to cast.

# Return value

Type: ValueArray