Using Block(C++) with Array Algorithms
As the name implies, Array Algorithms can be used with arrays.
But because a Block
(see
Block(C++)
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(C++)
Previous topic:
No More Array Errors (Part II) - Array_alg(C++)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005