首页 > 代码库 > link them together by means of pointers
link them together by means of pointers
Computer Science An Overview _J. Glenn Brookshear _11th Edition
An alternative to storing a heterogeneous array in a block of contiguous memory cells is to store each component in a separate location and then link them together by means of pointers. More precisely, if the array contains three components, then we find a place in memory to store three pointers, each of which points to one of the components (Figure 8.7b). If these pointers are stored in a block starting at address x, then the first component can be found by following the pointer stored at location x, the second component can be found by following the pointer at location x 1, and so forth.
This arrangement is especially useful in those cases in which the size of the array’s components is dynamic. For instance, by using the pointer system the size of the first component can be increased merely by finding an area in memory to hold the larger component and then adjusting the appropriate pointer to point to the new location. But if the array were stored in a contiguous block, the entire array would have to be altered.
Implementing Data Structures 数据结构的实现
Storing Arrays Heterogeneous Arrays 异构数组的存储
link them together by means of pointers