Abstract data types (ADTs) can be classified into the following types. Some complex ADTs are combinations of these three types.

Collections

A collection is, as its name suggests, a data structure that contains numerous data items. The data structure provides the means to access these data items individually. Different kinds of collections are distinguished according to the kinds of access that they allow. Some allow access to any data item at any time. Others only allow access to a single item, and that item does not change until it is removed or other items are added.

Random-Access Collections

Random-access collections permit access to any data item at any time. Most languages have built-in syntax for simple random-access collections such as arrays and C structs. Object-oriented languages have objects, which are a simple form of random access collection.

C structs and objects are very limited forms of random-access collections that allow data items (the fields of the record or members of a struct) to have different types. Individual fields are selected by specifying a field or member name. The limitation of records and structs is that the field or member name must be specified when the program is written. It cannot be a variable.

Arrays are collections in which all of the data items have the same type, and the individual items can be accessed by specifying an index into the array. The array index is usually an integer, but it may also be an enumerated type or a character. An array index can be a variable, allowing a single statement to select different data items at different times during the execution of a program.

A table is a data structure that generalizes the idea of an array. In a table, each data item is associated with a key, which is used by the data structure to locate data items. So the key plays the same role for general tables that the index does for arrays. Telephone directories and dictionaries provide good models for tables. The data items in a telephone book are addresses and telephone numbers. The name of a person is the key that is used for locating a particular data item. In a dictionary, a word is the key and its definitions are the data. In ADT terminology, a table is often called a dictionary. Tables are implemented in the Java standard class libraries implementing the java.util.Map interface.

Dispensers

Dispensers are collections that limit access to a single data item at a time. A paper cup dispenser is a good model for this kind of behavior. If you want to get a specific cup out of the dispenser, you first of all have to remove the ones below it. Dispensers allow data to be added at any time.

Different kinds of dispensers are distinguished according the order in which items become accessible.

Dispensers provide subprograms for adding data items and removing the accessible data item. In addition, they provide subprograms for examining the accessible data item and for determining if the dispenser is empty. Sometimes, they will provide a subprogram for determining the number of data items in the dispenser.

Streams and Iterators

Streams and iterators are both data structures that provide access (usually sequential) to data items in collections. The distinction between streams and iterators is not clear cut, but streams usually provide access to data in files or other data from outside the computer. In C, file variables are in fact stream structures. The term iterator is usually used for data structures that provide sequential access to data held in a collection such as a table or some type of dispenser.

Both streams and iterators maintain information about the current position in the collection, and provide subprograms for accessing the data at the current position and for advancing it. In addition, input streams and iterators must provide some method for determining when the data has been exhausted.

Streams and iterators often provide subprograms that simultaneously access data at the current position and, for input, advance the position. In C, accessing the data at the current position, advancing the current position, and determining when the data has been exhausted are all combined into single functions getc and putc for character-oriented input and output, or fgets and fputs for line-oriented input and output.

Subprograms are also needed to initialize the stream or iterator (C fopen). In short, streams and iterators provide subprograms that are needed to support the construction of loops for stepping through a body of data.

Although the data items in a file usually all have the same type, streams can be designed to treat groups of items as a single entity of a different type. For example, almost all programming languages provide built-in subprograms for reading a group of digits from a text file and converting the group into an integer. Similarly, output streams may be designed to provide grouping or ungrouping subprograms. Complex programs may use several layers of streams to process input into a form suitable for high level algorithms, or to process output into a desired format.

Relational Data Structures

Many programs work with data items with complex relationships. For example, a program for handling airline reservations needs one data type representing cities, but the program also needs to represent flights between cities. Many relational data structures are based on graphs. A graph contains two kinds of entities: vertices and edges, where an edge is a connection between two vertices, indicating some kind of relationship. For example, for an airline reservation program, cities would be represented by vertices in a graph and flights would be represented by edges.