Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
A Complete Guide to Programming in C++ part 78. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | chapter 33 Containers This chapter describes standard class templates used to represent containers for more efficient management of object collections.These include sequences such as lists and double ended queues container adapters such as stacks queues and priority queues associative containers such as sets and maps and bitsets. Besides discussing how to manage containers we will also be looking at sample applications such as bitmaps for raster images and routing techniques. 749 750 CHAPTER 33 CONTAINERS CONTAINER TYPES Sequences and associative containers Containers Sequences Associative Containers Arrays Stacks Queues Sets Maps Bitsets etc. CONTAINER TYPES 751 What is a Container Containers are used to store objects of the same type and provide operations with which these objects can be managed. These operations include object insertion deletion and retrieval. Memory is allocated for containers dynamically at runtime. Containers thus provide a safe and easy way to manage collections of objects. The C standard library provides various class templates for container management in the Containers Library. These classes can be categorized as follows sequential containers or sequences where the objects are arranged sequentially and access to an object can either be direct or sequential associative containers where the objects are generally organized and managed in a tree structure and can be referenced using keys. Sequences Sequential containers are distinguished by the operations defined for them which are either generic or restricted. Restricted operations such as appending at the end of a container have constant runtimes. That is the runtime is proportional to a fixed period of time and does not depend on the number of objects in the container. The following are sequential containers arrays which provide the same operations as C arrays but increase and decrease in size dynamically in contrast to C arrays queues which are managed on the FIFO First In First Out .