Book contents
- Frontmatter
- Contents
- Preface
- One Program Design
- Two Data Types
- Three Object-Oriented Programming Concepts
- Four Features of Programming Languages
- Five Object-Oriented Methods
- Six Inheritance and Polymorphism
- Seven OO Data Structures
- Eight Arrays and Matrices
- Nine Advanced Topics
- Appendix A Fortran 90 Overview
- Appendix B Selected Exercise Solutions
- Appendix C Companion C++ Examples
- Bibliography
- Glossary of Object-Oriented Terms
- Index
Seven - OO Data Structures
Published online by Cambridge University Press: 15 October 2009
- Frontmatter
- Contents
- Preface
- One Program Design
- Two Data Types
- Three Object-Oriented Programming Concepts
- Four Features of Programming Languages
- Five Object-Oriented Methods
- Six Inheritance and Polymorphism
- Seven OO Data Structures
- Eight Arrays and Matrices
- Nine Advanced Topics
- Appendix A Fortran 90 Overview
- Appendix B Selected Exercise Solutions
- Appendix C Companion C++ Examples
- Bibliography
- Glossary of Object-Oriented Terms
- Index
Summary
Data Structures
We have seen that F90 has a very strong intrinsic base for supporting the use of subscripted arrays. Fortran arrays can contain intrinsic data types as well as user-defined types (i.e., ADTs). One cannot directly have an array of pointers, but an array containing defined types that are pointers or that have components that are pointers is allowable. Arrays offer an efficient way to contain information and to insert and extract information. However, there are many times when creating an efficient algorithm dictates that we use some specialized storage method, or container, and a set of operations to act with that storage mode. The storage representation and the set of operations that are allowed for it are known as a data structure. How you store and retrieve an item from a container is often independent of the nature of the item itself. Thus, different instances of a data structure may produce containers for different types of objects. Data structures have the potential for a large amount of code reuse, which is a basic goal of OOP methods. In the following sections we will consider some of the more commonly used containers. We will begin with stacks and queues, which are illustrated in Figure 7.1.
Stacks
A stack is a data structure in which access is restricted to the last inserted object. It is referred to as a last-in first-out (LIFO) container. In other words, a stack is a container to which elements may only be inserted or removed at one end of the container called the top of the stack.
- Type
- Chapter
- Information
- Object-Oriented Programming via Fortran 90/95 , pp. 157 - 177Publisher: Cambridge University PressPrint publication year: 2003