PrevNextUpHome SophiaFramework UNIVERSE 5.3

13.7. Array and List

All elements of SFXArray is stored together into the consecutive variable memory area.

On the other hand, each element of SFXList is stored into the fragmented memory area and linked to the previous and next elements via the pointer.

Difference between SFXArray and SFXList is as follows:

Table 13.3. SFXArray and SFXList

Item SFXArray SFXList
Accessing an Element An element can be accessed directly by specifying the index in the operand of the SFXArray::operator[] operator or the argument of the SFXArray::Get / SFXArray::Set function. Sequential search using the iterator or the enumerator is also available. Though an element can be accessed by specifying the index in the argument of the SFXList::Get / SFXList::Set function, it takes that much more time than SFXArray since the link of the elements in the list needs to be traversed. Sequential search using the iterator or the enumerator is also available.
Inserting and Deleting an Element All elements after the element in question need to be moved. In case the memory reallocation is necessary, all elements need to be moved. Only updating the pointers to the neighbour elements is needed.
Memory Consumption Per Item Only memory for the value of the element is needed. Memory for the value of the element and the pointers to the neighbour elements is needed.
Total Memory Efficiency Since the memory area increases by the cluster size set with the SFXArray::SetCluster function, the unused memory area exists. Since the memory area increases by the size necessary for one element, the unused memory area does not exist.