ebook img

A Systematic Catalogue of Reusable Abstract Data Types PDF

352 Pages·1990·4.699 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview A Systematic Catalogue of Reusable Abstract Data Types

Lecture Notes ni Computer Science detidE yb .G Goos dna .J sinamtraH 460 negr0J lhU snaH Albrecht dimhcS A citametsyS eugolataC of elbasueR tcartsbA ataD sepyT IIIIIII galreV-regnirpS nilreB grebledieH New kroY nodnoL siraP oykoT Hong Kong anolecraB Editorial Board D. Barstow W. Brauer R Brinch Hansen D. Gries D. Luckham C. Moler A. Pnueli G. Seegm~iller .1. Stoer N. Wirth Authors negr~LJ Uhl Forschungszentrum Informatik, Universit&t Karlsruhe Haid-und-Neu-StraBe 10-14, W-7500 Karlsruhe, FRG Hans Albrecht Schmid Fachbereich Informatik, Fachhochschule Konstanz BrauneggerstraBe, W-7750 Konstanz, FRG CR Subject Classification (1987): D.2.2, D.2.m, D.3.3, E.2 ISBN 3-540-53229-3 Springer-Verlag Berlin Heidelberg New York ISBN 0-387-53229-3 Springer-Verlag NewYork Berlin Heidelberg work This sirights All copyright. to subject era ,devreser the of part or whole the whether lairetam rights the specifically concerned, is of re-use reprinting, translation, of illustrations, ,noitaticer ,gnitsacdaorb on reproduction smliforcim ways, other in or dna data in storage .sknab noitacilpuD only is thereof parts or publication this of dettimrep the under snoisivorp the of namreG Copyright waL of rebmetpeS ,9 ,5691 version, current its in dna copyright a eef always must eb paid. act prosecution the under fall Violations of Copyright German the .waL © galreV-regnirpS Heidelberg Berlin 0991 ehT with rests A) (Appendix Specifications Ada the for copyright eht .srohtua in Printed ynamreG Printing dna Beltz, Druckhaus binding: .rtsgreB/hcabsmeH paper acid-free on 2145/3140-543210- Printed Foreword More and more, people are starting to think of software as an investment. As a conse- quence, the concern is growing on how to develop software that can be maintained for long periods of time and adapted to new uses easily. This lead to a broad interest in software reusability. The motto "don't redo what is there already" is gaining support. Reusabihty can be envisaged at the level of entire systems or at the level of individual pieces or components of a system. Source code can be reused, but also test cases, designs, specifications and even requirements. Software is considered reusable if it can be easily employed for applications it was not intended for originally. The reuse technology that appears to be most mature is that of generalized compo- nents, frequently referred to as building blocks. Libraries of building blocks have been developed and successfully employed in several application areas. At the core of such libraries, particularly if they are intended for applications in system programming, are basic data structures. Ideally they are offered in the f0rm of abstract data types. The concept of abstract data types is one of the most successful and pervasive struc- turing concepts introduced into the software development practice. It embodies such software engineering principles as separation of interface and implementation informa- tion hidhlg, localization of functions, and parameterization. Their theoretical prop- erties have been studied quite extensively and they are amenable to algebraic and axiomatic specifications. Designing with abstract data types fosters reuse because it encourages going from a special situation to the more general, or generic, case through classification and abstraction. Building on a strong technical foundation laid by Kleine ]8[ several years ago, Uhl and Schmid have designed and implemented a new set of abstract data types that are described in this book. The implementations in this catalogue are done in the programming language Ada. In contrast to previous similar efforts, Uhl and Schmid introduce two major new ideas. They try to achieve the utmost degree of consistency as fai" as the external interfaces are concerned. They then device a hierarchical relationship between the various data types which serves as the basis for the implementation, i.e. the more complex members are built out of the more elementary ones - reuse within reuse. The result of this is a very high number of variants that can be produced from a rather small code base. VI Since the advantages of this approach in terms of development cost, code quMity, learning effort and maintenance are quite obvious, I like to call this a second generation catalogue. In addition to the catalogue itself, the authors give valuable practical guidelines on how to design using abstract data types. A comprehensive example at the end of the book illustrates the ideas through a realistic application. Both authors have spent several years on industrial software projects or on joint studies between industry and academia. They haveh elped to introduce formal design methods and abstract data types. The entire text reflects this experience. Albert Endres, BSblingen slnemgdelwonkcA Our thanks are due to the institution and persons who made this work possible, and to our colleagues with whom we had fruitful discussions. Especially, we want to acknowledge • the support of IBM and, in particular, of Albert Endres, who established the department of research and development in reusability at the IBM BSblingen development laboratory as early as 1983, and • the base laid by Karl Kleine from FZI Karlsruhe, who made - under the contract of this department - the first steps into the land of catalogues and libraries of abstract data types as reusable components in 1984. Jiirgen Uhl, Karlsruhe Hans Albrecht Schmid, Konstanz May 1990 C o n t e n t s 1 Introduction 1 2 Motivation and Objectives 5 2.1 Simplicity of the Library Structure .................... 6 2.2 Functional Completeness .......................... 8 2.3 Completeness of Implementation Variants ................ 10 2.4 Maintainability ............................... 12 How to Reuse Abstract Data Types 15 3.1 Working With Data Structures - A Counter-Example ......... 16 3.1.1 Selecting a Data Structure ..................... 17 3.t.2 Designing the Operations on the Data Structure ........ 17 3.1.3 Conclusion ............................. 18 3.2 Reusing Abstract Data Types ....................... 19 3.2.1 Selecting "Low Level" Abstract Data Types ........... 20 3.2.2 Selecting the "Right" Abstract Data Types ........... 23 3.U3 An Abstract Specification and Solution ............. 25 3.2.4 Selection of an Abstract Data Type Variant ........... 27 3.3 Reuse Paradigm .............................. 29 4 Structure of the Catalogue 37 4.1 The Implementation Hierarchy ...................... 37 4.2 The Abstract Data, Types - an Overview ................. 39 4.2.1 List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 4.2.2 Stack ................................ 40 4.2.3 Queue and Deque ......................... 41 4.2.4 Tree ................................. 41 4.2.5 Order ................................ 41 4.2.6 Set .................................. 42 4.2.7 Map ................................. 42 VIII 4.2.8 Bag ................................. 42 4.3 Variants of Building Blocks ........................ 42 5 Structure of the Building Blocks 45 5.1 General Properties of the Data Types .................. 46 5.1.1 Objects and Values ......................... 46 5.1.2 Structure Sharing ......................... 47 5.1.3 Compact and Dispersed Representations ............. 48 5.1.4 Recursive Composition ....................... 49 5.2 Types .................................... 50 5.2.1 The Type STRUCT ........................ 50 5.2.2 The Type INDEX ......................... 51 5.2.3 INSERT_POSITIONs and REMOVE_POSITIONs ....... 53 5.2.4 Structure PARTs .......................... 54 5.2.5 The Type ITERATION_ORDER ................. 54 5.3 Operations ................................. 54 5.3.1 Constructors ............................ 57 5.3.2 Operations Based on Indices ................... 73 5.3.3 Access by Position Count ..................... 76 5.3.4 Selector Operations ........................ 77 5.3.5 Iterators ............................... 80 5.3.6 P~duction .............................. 86 5.3.7 Find, Skip and Count ....................... 89 5.3.8 Existential and Universal Quantifiers ............... 90 5.3.9 Order Dependent Operations ................... 91 5.3.10 Hash Operation ........................... 93 5.4 Generic Parameters ............................. 94 5.4.1 Equal, Copy, and Transfer ..................... 95 5.4.2 Initialization ............................ 95 5.4.3 Deallocation ............................ 96 5.4.4 An Example ............................ 96 5.4.5 Key-Info Types ........................... 98 5.4.6 Accessed Elements ......................... 98 5.4.7 Bounded Collections ........................ 98 5.5 Variant Parameters ............................. 99 5.5.1 Classes of Element Types ..................... 99 5.5.2 Collection Management ...................... 105 5.5.3 Consistency Checking ....................... 108 5.5.4 Algorithms vs. Data ........................ 108 5.5.5 Summary .............................. 109 IX 6 The Building Blocks 111 6.1 Linked Collections ............................. 112 6.1.1 Synopsis ............................... 112 6.1.2 Types and Operations ....................... 112 6.1.3 Implementation Overview ..................... 113 6.1.4 Specific Generic Parameters .................... 114" 6.1.5 Specific Variants .......................... 114 6.1.6 General Variants .......................... 114 6.1.7 Representation of Linked Collections ............... 116 6.2 Tabular Collections ............................. 117 6.2.1 Synopsis ............................... 117 6.2.2 Types and Operations ....................... 117 6.2.3 Implementation Overview ..................... 118 6.2.4 Specific Generic Parameters .................... 118 6.2.5 Specific Variants .......................... 119 6.2.6 General Variants .......................... 119 6.3 Hash tables ................................. 121 6.3.1 Synopsis ............................... 121 6.3.2 Types and Operations ....................... 121 6.3.3 Implementation Overview ..................... 122 6.3.4 Specific Generic Parameters .................... 123 6.3.5 Specific Variants .......................... 123 6.3.6 General Variants .......................... 126 6.3.7 Combination of Variants ...................... 126 6.3.8 Representation of Hash tables ................... 127 6.4 Lists, Linked Lists, Tabular Lists ..................... 128 6.4.1 Synopsis ............................... 128 6.4.2 Types and Operations ....................... 128 6.4.3 Implementation Overview ..................... 138 6.4.4 List Specific Variants ........................ 139 6.4.5 General Variants of Lists ..................... 139 6.4.6 Combination of List Variants ................... 140 6.4.7 Linked List Specific Variants ................... 140 6.4.8 General Variants of Linked Lists ................. 142 6.4.9 Combination of Linked List Variants ............... 142 6.4.10 Representation of Linked List by Linked Collections ...... 142 6.4.11 Tabular List Specific Variants ................... 143 6.4.12 General Variants of Tabular Lists ................. 146 6.4.13 Representation of Tabular Lists by Tabular Collections .... 146 6.5 Stacks .................................... 148 6.5.1 Synopsis ............................... 148 6.5.2 Types and Operations ....................... 148 X 6.5.3 Implementation Overview ..................... 149 6.5.4 Specific Variants .......................... 150 6.5.5 General Variants .......................... 150 6.5.6 Combination of Variants ......... . ............ 151 6.5.7 Representation Specific Variants ................. 151 6.5.8 Representation of Stacks by Lists ................. 153 6.6 seueuQ and Deques ............................. 154 6.6.1 Synopsis ................................. 154 6.6.2 Types and Operations ....................... 154 6.6.3 Implementation Overview ..................... 155 6.6.4 Specific Variants .......................... 155 6.6.5 General Variants .......................... 155 6.6.6 Combination of Variants ...................... 156 6.6.7 Representation Specific Variants ................. 156 6.6.8 Representation of Queues and Deques by Lists ......... 157 6.7 Trees, Linked Trees, Tabular Trees 158 . . . . . . . . . . . . . . . . . . . . 6.7.1 Synopsis ............................... 158 6,7,2 Types and Operations ....................... 159 6.7.3 Implementation Overview ..................... 167 6.7,4 Specific Generic Parameters .................... 168 6.7.5 Tree Specific Variants ....................... 168 6.7.6 General Variants of Trees ..................... 169 6.7.7 Combination of Tree Variants ................... 169 6,7.8 Linked Tree Specific Variants ................... 169 6.7.9 General Variants of Linked Trees ................. 171 6.7.10 Combination of Linked Tree Variants ............... 171 6.7.11 Representation of Linked Trees by Linked Collections ..... 172 6.7,12 Tabular Tree Specific Variants .................. 173 6.7.13 General Variants of Tabular Trees ................ 174 6.7.14 Representation of Tabular Trees by Tabular Collections .... 174 6.8 Orders .................................... 176 6.8.1 Synopsis ............................... 176 6.8.2 Types and Operations ....................... 177 6.8.3 Implementation Overview ..................... 178 6.8,4 Specific Generic Parameters ........... . ......... 178 6.8.5 Specific Variants .......................... 179 6.8.6 General Variants .......................... 179 6.8.7 Combination of Variants ...................... 180 6.8.8 Representation Specific Variants ................. 180 6.8.9 Representation of Orders by Lists and Trees ........... 183 6.9 Sets and Maps ............................... 185 6.9.1 Synopsis ............................... 185 XI 6.9.2 Types and Operations ....................... 185 6.9.3 Implementation Overview ..................... 187 6.9.4 Specific Generic Parameters .................... 188 6.9.5 Specific Variants .......................... 188 6.9.6 General Variants .......................... 188 6.9.7 Combination of Variants ...................... 189 6.9.8 Representation Specific Variants ................. 189 6.9.9 Representation of Sets and Maps ................. 193 6.10 Bags ..................................... 194 6.10.1 Synopsis ............................... 194 6.10.2 Types and Operations ....................... 194 6.10.3 Implementation Overview ..................... 195 6.10.4 Specific Generic Parameters .................... 196 6.10.5 Specific Variants .......................... 196 6.10.6 General Variants .......................... 197 6.10.7 Combination of Variants ...................... 197 6.10.8 Representation Specific Variants ................. 197 6.10.9 Representation of Bags ...................... 198 Technical Issues 199 7.1 Selection of Building Block Variants ................... 199 7.2 Ada Design Decisions ........................... 200 7.2.1 Dispersion of Structures Objects ................. 202 7.2.2 Composition of Data Types .................... 204 7.2.3 Storage Management ........................ 205 7.3 Deficiencies and Open Problems ..................... 206 8 Case Study: A File Compression System 209 8.1 The Overall Task .... ~ .......................... 209 8.2 Sem'ch for Reusable Building Blocks (Phase 1) ............. 210 8.3 Functional Decomposition (Phase 1) ................... 210 8.4 Modular Decomposition .......................... 211 8.4.1 Words, Codes and Items ...................... 212 8.4.2 The Word-Frequency Collection .................. 214 8.4.3 The Word-Code Map ....................... 215 8.4.4 The Code-Word Map ....................... 216 8.5 Search for Reusable Building Blocks (Phase 2) ............. 217 8.5.1 Words, Codes and Items ...................... 219 8.5.2 The Word-Frequency Collection .................. 219 8.5.3 The Word-Code Map ....................... 223 8.5.4 Decompression ........................... 224

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.