Abstract Data Types
Abstract data types (ADTs) are a generalization of
the primitive data types (e.g., integer, real, boolean)
supported by most programming languages.
An ADT encapsulates the state (i.e., variables)
needed to represent the abstract type,
and a set of operations on that type.
Example of an ADT String:
CONST MAXSTRING = 5000;
(* string is an index into the string space *)
TYPE string = integer;
VAR stringspace = ARRAY 1:MAXSTRING of char;
APPEND(letter:char; var s:string);
CONCATENATE(s1,s2:string; var s3:string);
Important properties of an abstract data type include:
- an external interface that specifies
the valid operations for the ADT; these operations are the
only means for accessing the type.
- (possibly multiple) implementations for the ADT,
whose details are not visible to the user of the ADT.