Skip to main content Accessibility help
×
Hostname: page-component-7bb8b95d7b-2h6rp Total loading time: 0 Render date: 2024-09-28T17:22:57.549Z Has data issue: false hasContentIssue false

24 - Container Library

Published online by Cambridge University Press:  05 July 2014

Get access

Summary

Amajor feature of the predefined library of Ada 2012 is the container library. This is rather extensive and merits this separate chapter on its own.

The main part of the library comprises several generic packages for the manipulation of various kinds of important data structures. These structures are vectors, doubly linked lists, maps and sets (both hashed and ordered), multiway trees, a holder (or wrapper), and various task safe queues. There are also generic packages for sorting arrays and other general structures.

Organization of library

The container library comprises a root package Ada.Containers plus various child generic packages. The main generic packages form three groups. The first group concerns objects of definite types; the second group concerns indefinite types, and the third group has bounded capacity for objects of definite types.

It will be remembered that an indefinite (sub)type is one for which we cannot declare an object without giving a constraint (either directly or indirectly from its initial value).

The reason for distinct containers for definite and indefinite types concerns efficiency. It is much easier to manipulate definite types and although the packages for indefinite types can be used for definite types, this would be rather inefficient.

Another consideration is reliability. For high integrity applications it is generally unacceptable to use dynamic storage allocation. Accordingly, a separate group of containers with bounded capacity is provided for definite types.

Note that there are no bounded containers for indefinite types because objects of indefinite types (such as the type String) by their very nature are of variable size and thus inevitably need dynamic storage management.

The containers can also be categorized in other ways.

Sequence containers – these hold sequences of elements. There are packages for manipulating vectors and for manipulating linked lists. These packages have much in common. But they have different behaviours in terms of efficiency according to the pattern of use. In general (with some planning) it should be possible to change from one to the other with little effort.

Multiway tree containers – these hold elements as a multiway tree. They have much in common with the sequence containers.

Associative containers – these associate a key with each element and then store the elements in order of the keys. There are packages for manipulating hashed maps, ordered maps, hashed sets and ordered sets.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2014

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Container Library
  • John Barnes
  • Book: Programming in Ada 2012
  • Online publication: 05 July 2014
  • Chapter DOI: https://doi.org/10.1017/CBO9781139696616.035
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Container Library
  • John Barnes
  • Book: Programming in Ada 2012
  • Online publication: 05 July 2014
  • Chapter DOI: https://doi.org/10.1017/CBO9781139696616.035
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Container Library
  • John Barnes
  • Book: Programming in Ada 2012
  • Online publication: 05 July 2014
  • Chapter DOI: https://doi.org/10.1017/CBO9781139696616.035
Available formats
×