The notion of external memory includes a large number of possible
different devices, each of which has its own block size and is
accessed with its own collection of system calls.  To simplify the
exposition of this chapter so that we can focus on the common ideas, we
encapsulate external memory devices with an object called a 
 .
A
.
A 
 stores a collection of memory blocks, each of size
 stores a collection of memory blocks, each of size  .
Each block is uniquely identified by its integer index.  A
.
Each block is uniquely identified by its integer index.  A 
 supports these operations:
supports these operations:
 : Return the contents of the block whose index is
: Return the contents of the block whose index is 
 .
.
 : Write contents of
: Write contents of 
 to the block whose
    index is
 to the block whose
    index is 
 .
.
 : Return a new index and store the contents of
: Return a new index and store the contents of 
 at this index.
    at this index.
 : Free the block whose index is
: Free the block whose index is 
 .  This indicates
    that the contents of this block are no longer used so the external
    memory allocated by this block may be reused.
.  This indicates
    that the contents of this block are no longer used so the external
    memory allocated by this block may be reused.
The easiest way to imagine a 
 is to imagine it as storing a
file on disk that is partitioned into blocks, each containing
 is to imagine it as storing a
file on disk that is partitioned into blocks, each containing  bytes.
In this way,
 bytes.
In this way, 
 and
 and 
 simply read and write
bytes
 simply read and write
bytes 
 of this file.  In addition, a simple
 of this file.  In addition, a simple
 could keep a free list of blocks that are available
for use. Blocks freed with
 could keep a free list of blocks that are available
for use. Blocks freed with 
 are added to the free list.
In this way,
 are added to the free list.
In this way, 
 can use a block from the free list or,
if none is available, append a new block to the end of the file.
 can use a block from the free list or,
if none is available, append a new block to the end of the file.
opendatastructures.org