Using Block(3C++) with Array Algorithms
As the name implies, Array Algorithms can be used with arrays.
But because a Block
(see
Block(3C++)
and Part I of this tutorial), can
always be used wherever an array is called for,
Array Algorithms can also be used
with Blocks.
This is not an accident. In fact, Blocks and Array Algorithms were actually
designed to be used together.
A major design goal was to partition all array concerns
into two disjoint sets:
storage management concerns and algorithmic concerns.
Consider the problem of inserting an element into a sorted array.
The issue of what to do
when the array is initially full
(increase the size of the array) is handled by Block,
while the insertion algorithm
(find the cell where the element belongs, move some
elements to the right by one position in order to free the cell,
store the element
into the cell) is handled by an Array Algorithm.
Next topic:
An array-based implementation of Set(3C++)
Previous topic:
No More Array Errors (Part II) - Array_alg(3C++)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004