Skip to content

class DoubleArray

DoubleArray is the double implementation of ValueArray. See ValueArray for a description.

See also: ValueArray

Properties

PropertyDescription
AlternativeNameA string that can be used to identify the array in collections. (Inherited from Array)
ItemCountThe 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 cannot exceed INT_MAX. (Inherited from Array)
NameThe name of the DoubleArray object. (Inherited from Object)
TupleCountThe tuple count, meaning how many tuples are in the array. If resized to larger array, the new tuples will not be set to anything. (Inherited from Array)
TupleSizeThe 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. (Inherited from Array)

Methods

MethodDescription
AddItemAdds an item to the list, allocates memory as needed to enlarge the list. If many items are being put into the list, use Resize to set the size of the new list (only one reallocation needed) and then use SetItem() / SetTuple() to set the items directly.
AddObserverAdds a user-defined observer object to the interface, that will receive events from the interface. (Inherited from Object)
AddTupleAdds a tuple to the list. Reallocates the list if needed. If many items are being put into the list, use Resize to set the size of the new list (only one reallocation needed) and then use SetItem() / SetRealTuple() to set the items directly.
AppendArrayAppends an array to this array. The array must be a descendant of ValueArray. For best performance, append arrays of the same basic type. (Inherited from Array)
ClearClears the array and sets the tuple count to 0. Tuple size and name remains the same though. (Inherited from Array)
CompareTuplesCompareTuples 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. (Inherited from Array)
CopyRangeCopyRange 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. (Inherited from Array)
CopyTupleCopyTuple 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. (Inherited from Array)
DeepCopyCopies data from another array. The arrays must have the same underlying data types. (Inherited from Array)
EqualsCompares this array, including all its contents, to another array. (Inherited from Array)
ExtractTuplesExtracts 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). (Inherited from Array)
GetBaseTypeReturns the id of the basic type that the array is based on The ids are listed in the BaseTypes enumeration. (Inherited from Array)
GetClassGet the name of the DoubleArray class. (Inherited from Object)
GetDataReturns all tuples in the array as a single item array.
GetDataRangeReturns a range of tuples in the array.
GetItemGets the value of an item in the list. The id of the item is the exact location of the item (TupleId * TupleSize + Index of item in tuple) Warning! No range checking is done.
GetMaxItemIdReturns 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. (Inherited from Array)
GetMaxTupleIdReturns 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. (Inherited from Array)
GetRealItemGetRealItem() 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. (Inherited from ValueArray)
GetTupleGets a tuple in the list. The id is the id of the tuple that is being fetched. Warning! No range checking is done.
IndexedCopyCopies 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. (Inherited from Array)
IsAReturns true if DoubleArray is a or is a descendant of the class named as the type parameter. (Inherited from Object)
IsEmptyReturns true if the list is empty. (Inherited from Array)
IsNullReturns true if the DoubleArray object is invalid. (Inherited from Object)
IsSameObjectAsReturns true if the DoubleArray object is valid. (Inherited from Object)
NewCopyCreates 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. (Inherited from Array)
NewPackedCopyLike 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. (Inherited from Array)
NonNullReturns true if the DoubleArray object is valid. (Inherited from Object)
PrintInfoPrints the content/info of the DoubleArray object to the log. (Inherited from Object)
RemoveObserverRemoves a previously added observer object. (Inherited from Object)
SetDataSet the array from a range of data values. Note that the array will be resized to the size of the items. Note that the source_item_count is the number of items to set, NOT the number of tuples.
SetDataFromMemoryPtrSet the array from a range of data values in a raw memory block. The array will be resized to the size of the tuples. Please set the tuple size before calling this method. Note! that the source_tuple_count is the number of TUPLES to set, not the number of items. Note! This method is intended for advanced users who want to get maximum performance. No range checking is done in this method, and your code will crash if your read area is not large enough.
SetDataRangeSet a part of the array from a range of data values. Note that the array will be resized to contain the size of the items. Note that the source_item_count is the number of items to set, NOT the number of tuples, but start_tuple_id IS the first tuple index to update.
SetItemSets an item in the list. The id of the item is the exact location of the item (TupleId * TupleSize + Index of item in tuple) Warning! No range checking is done.
SetRealItemSetRealItem() 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. (Inherited from ValueArray)
SetTupleSets a tuple in the list. The id is the id of the tuple that is being updated. Warning! No range checking is done.

Static methods

MethodDescription
IsClassAReturns true if the class is a or is a descendant of the class named as the type parameter. (Inherited from Object)
SafeCastSafeCast makes sure the input object is of a class that can be cast into spDoubleArray, and if this is the case, returns the object cast into spDoubleArray. (Inherited from Object)

Properties details

AlternativeName

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

Syntax

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

// Getter
spString GetAlternativeName() const;

SetAlternativeName parameters

TypeNameMinMaxDescription
const char *valueThe 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 cannot exceed INT_MAX.

Syntax

cpp
// Setter
void SetItemCount( unsigned int value ) const;

// Getter
unsigned int GetItemCount() const;

SetItemCount parameters

TypeNameMinMaxDescription
unsigned intvalue1INT_MAXThe desired item count.

GetItemCount return value

Type: unsigned int

Default: 1

Name

The name of the DoubleArray object. (Inherited from Object)

Syntax

cpp
// Setter
void SetName( const char * name ) const;

// Getter
spString GetName() const;

SetName parameters

TypeNameMinMaxDescription
const char *nameNew name of the object.

GetName return value

Type: spString

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

cpp
// Setter
void SetTupleCount( unsigned int value ) const;

// Getter
unsigned int GetTupleCount() const;

SetTupleCount parameters

TypeNameMinMaxDescription
unsigned intvalue1INT_MAXThe 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

cpp
// Setter
void SetTupleSize( unsigned int value ) const;

// Getter
unsigned int GetTupleSize() const;

SetTupleSize parameters

TypeNameMinMaxDescription
unsigned intvalue11024The desired tuple size.

GetTupleSize return value

Type: unsigned int

Default: 1

Methods details

AddItem

Adds an item to the list, allocates memory as needed to enlarge the list. If many items are being put into the list, use Resize to set the size of the new list (only one reallocation needed) and then use SetItem() / SetTuple() to set the items directly.

Syntax

cpp
void AddItem( double value ) const;

Parameters

TypeNameMinMaxDescription
doublevalueThe value of the item.

AddObserver

Adds a user-defined observer object to the interface, that will receive events from the interface. (Inherited from Object)

Syntax

cpp
rid AddObserver( const spObserver & observer ) const;

Parameters

TypeNameMinMaxDescription
ObserverobserverObserver is the object that will receive events.

Return value

Type: rid

AddTuple

Adds a tuple to the list. Reallocates the list if needed. If many items are being put into the list, use Resize to set the size of the new list (only one reallocation needed) and then use SetItem() / SetRealTuple() to set the items directly.

Syntax

cpp
void AddTuple( const double *tuple_doubleInputDataPtr ) const;

Parameters

TypeNameMinMaxDescription
DoubleDatatupleThe value(s) of the tuple.

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

cpp
void AppendArray( const spArray & source ) const;

Parameters

TypeNameMinMaxDescription
ArraysourceThe 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

cpp
void Clear() const;

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

cpp
int CompareTuples( const spArray & otherArray , rid tupleId , rid otherTupleId ) const;

Parameters

TypeNameMinMaxDescription
ArrayotherArrayThe other array to compare with.
ridtupleId0MaxTupleIdThe tuple from this array to use for comparison.
ridotherTupleId0The 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

cpp
void CopyRange( const spArray & sourceArray , rid startDestId , rid startSrcId , unsigned int count ) const;

Parameters

TypeNameMinMaxDescription
ArraysourceArrayThe source array to copy from.
ridstartDestIdThe first destination tuple id.
ridstartSrcIdThe first source tuple id.
unsigned intcountThe 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

cpp
void CopyTuple( const spArray & sourceArray , rid destId , rid srcId ) const;

Parameters

TypeNameMinMaxDescription
ArraysourceArrayThe source array to copy from.
riddestId0MaxTupleIdThe tuple index in this array to copy into.
ridsrcId0The 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

cpp
void DeepCopy( const spArray & source ) const;

Parameters

TypeNameMinMaxDescription
ArraysourceThe source array to copy from.

Equals

Compares this array, including all its contents, to another array.

Syntax

cpp
bool Equals( const spArray & other ) const;

Parameters

TypeNameMinMaxDescription
ArrayotherThe other array to compare against.

Return value

Type: bool

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

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

Parameters

TypeNameMinMaxDescription
ArraydestThe array that will store the extracted tuples.
ridstart0MaxTupleIdThis array tuple index where the extraction starts.
unsigned intcountINT_MAXThe 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

cpp
Simplygon::EBaseTypes GetBaseType() const;

Parameters

GetBaseType takes no parameters.

Return value

Type: EBaseTypes

KeyValueComment
TYPES_ID_VOID0
TYPES_ID_BOOL1
TYPES_ID_CHAR2
TYPES_ID_UCHAR3
TYPES_ID_SHORT4
TYPES_ID_USHORT5
TYPES_ID_INT6
TYPES_ID_UINT7
TYPES_ID_LONG8
TYPES_ID_ULONG9
TYPES_ID_FLOAT10
TYPES_ID_DOUBLE11
TYPES_ID_REAL12
TYPES_ID_RID13
TYPES_ID_RCHAR14
TYPES_ID_RHANDLE15
TYPES_ID_STRING16
TYPES_ID_OBJECT17

GetClass

Get the name of the DoubleArray class. (Inherited from Object)

Syntax

cpp
spString GetClass() const;

Parameters

GetClass takes no parameters.

Return value

Type: spString

GetData

Returns all tuples in the array as a single item array.

Syntax

cpp
spDoubleData GetData() const;

Parameters

TypeNameMinMaxDescription

Return value

Type: spDoubleData

GetDataRange

Returns a range of tuples in the array.

Syntax

cpp
spDoubleData GetDataRange( rid start_tuple_id , unsigned int tuple_count ) const;

Parameters

TypeNameMinMaxDescription
ridstart_tuple_id0MaxTupleIdThe first id in the range.
unsigned inttuple_countThe number of tuples in the range.

Return value

Type: spDoubleData

GetItem

Gets the value of an item in the list. The id of the item is the exact location of the item (TupleId * TupleSize + Index of item in tuple) Warning! No range checking is done.

Syntax

cpp
double GetItem( rid id ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxItemIdThe id of the item.

Return value

Type: double

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

cpp
rid GetMaxItemId() const;

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

cpp
rid GetMaxTupleId() const;

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

cpp
real GetRealItem( rid id ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxItemIdThe item to get.

Return value

Type: real

GetTuple

Gets a tuple in the list. The id is the id of the tuple that is being fetched. Warning! No range checking is done.

Syntax

cpp
spDoubleData GetTuple( rid id ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxTupleIdThe id of the tuple.

Return value

Type: spDoubleData

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

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

Parameters

TypeNameMinMaxDescription
ArraysourceThe array from which to copy tuples.
RidArrayidtableThe array with the tuple indices to copy.
ridstartIdThe first tuple that will receive the copied values.

IsA

Returns true if DoubleArray is a or is a descendant of the class named as the type parameter. (Inherited from Object)

Syntax

cpp
bool IsA( const char * type ) const;

Parameters

TypeNameMinMaxDescription
const char *typeName of the class to check if DoubleArray is, or is a descendant of.

Return value

Type: bool

IsEmpty

Returns true if the list is empty.

Syntax

cpp
bool IsEmpty() const;

Parameters

IsEmpty takes no parameters.

Return value

Type: bool

IsNull

Returns true if the DoubleArray object is invalid. (Inherited from Object)

Syntax

cpp
bool IsNull() const;

Parameters

IsNull takes no parameters.

Return value

Type: bool

IsSameObjectAs

Returns true if the DoubleArray object is valid. (Inherited from Object)

Syntax

cpp
bool IsSameObjectAs( const spObject & object ) const;

Parameters

TypeNameMinMaxDescription
ObjectobjectObject to compare with.

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

cpp
spArray NewCopy( bool copyData ) const;

Parameters

TypeNameMinMaxDescription
boolcopyDataIf 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

cpp
spArray NewPackedCopy( const spRidArray & indexArray ) const;

Parameters

TypeNameMinMaxDescription
RidArrayindexArrayThe optional array that will receive the indices of the remapped tuples.

Return value

Type: Array

NonNull

Returns true if the DoubleArray object is valid. (Inherited from Object)

Syntax

cpp
bool NonNull() const;

Parameters

NonNull takes no parameters.

Return value

Type: bool

PrintInfo

Prints the content/info of the DoubleArray object to the log. (Inherited from Object)

Syntax

cpp
void PrintInfo() const;

Parameters

PrintInfo takes no parameters.

RemoveObserver

Removes a previously added observer object. (Inherited from Object)

Syntax

cpp
void RemoveObserver( rid observerId ) const;

Parameters

TypeNameMinMaxDescription
ridobserverIdObserverId is the id returned by AddObserver when the observer was added.

SetData

Set the array from a range of data values. Note that the array will be resized to the size of the items. Note that the source_item_count is the number of items to set, NOT the number of tuples.

Syntax

cpp
void SetData( const double *source_items_doubleInputDataPtr , unsigned int source_item_count ) const;

Parameters

TypeNameMinMaxDescription
DoubleDatasource_itemsThe array to copy from.
unsigned intsource_item_countThe number of items in the array.

SetDataFromMemoryPtr

Set the array from a range of data values in a raw memory block. The array will be resized to the size of the tuples. Please set the tuple size before calling this method. Note! that the source_tuple_count is the number of TUPLES to set, not the number of items. Note! This method is intended for advanced users who want to get maximum performance. No range checking is done in this method, and your code will crash if your read area is not large enough.

Syntax

cpp
void SetDataFromMemoryPtr( void *mem_area_voidInputDataPtr , unsigned int source_tuple_count , unsigned int item_stride , unsigned int tuple_stride ) const;

Parameters

TypeNameMinMaxDescription
voidmem_areaThe array to copy from
unsigned intsource_tuple_countThe number of items in the array
unsigned intitem_strideThe number of bytes between the address of an item to the address of the next. If items are consecutive in memory, this stride should be the size of on item.
unsigned inttuple_strideThe number of bytes between the address of the first item in one tuple to the address of the first item in the next tuple. E.g, if the items are copied from an array of structs, this stride should be the size of one of the struct objects in the array.

SetDataRange

Set a part of the array from a range of data values. Note that the array will be resized to contain the size of the items. Note that the source_item_count is the number of items to set, NOT the number of tuples, but start_tuple_id IS the first tuple index to update.

Syntax

cpp
void SetDataRange( rid start_tuple_id , const double *source_items_doubleInputDataPtr , unsigned int source_item_count ) const;

Parameters

TypeNameMinMaxDescription
ridstart_tuple_id0MaxTupleIdwhere to start copy to in this array.
DoubleDatasource_itemsThe array to copy from.
unsigned intsource_item_countThe number of items in the array.

SetItem

Sets an item in the list. The id of the item is the exact location of the item (TupleId * TupleSize + Index of item in tuple) Warning! No range checking is done.

Syntax

cpp
void SetItem( rid id , double value ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxItemIdThe id of the item.
doublevalueThe new value of the item.

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

cpp
void SetRealItem( rid id , real value ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxItemIdThe item to set.
realvalueThe real value to set the item to.

SetTuple

Sets a tuple in the list. The id is the id of the tuple that is being updated. Warning! No range checking is done.

Syntax

cpp
void SetTuple( rid id , const double *tuple_doubleInputDataPtr ) const;

Parameters

TypeNameMinMaxDescription
ridid0MaxTupleIdThe id of the tuple.
DoubleDatatupleThe new value(s) of the tuple.

Static methods details

IsClassA

Returns true if the class is a or is a descendant of the class named as the type parameter. (Inherited from Object)

Syntax

cpp
static bool IsClassA( const char * type ) const;

Parameters

TypeNameMinMaxDescription
const char *typeName 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 spDoubleArray, and if this is the case, returns the object cast into spDoubleArray. (Inherited from Object)

Syntax

cpp
static spDoubleArray SafeCast( const spObject & object ) const;

Parameters

TypeNameMinMaxDescription
ObjectobjectObject to cast.

Return value

Type: DoubleArray