STL Containers
From CometWiki
(→IB Reference) |
m (→Container Types) |
||
Line 17: | Line 17: | ||
====List==== | ====List==== | ||
- | Lists are | + | Lists are sequence containers that are designed for efficient iteration. They provide access to the front and the back of the list, and are doubly-linked which means you can iterate efficiently both backwards and forwards. |
====Stack==== | ====Stack==== | ||
- | Stacks are | + | Stacks are lists designed with LIFO (Last In, First Out) access. That is, the last element you add to the stack will be the first element removed. |
====Queue==== | ====Queue==== | ||
- | Queues are | + | Queues are lists designed with FIFO (First In, First Out) access. That is, the first element you added to the stack will be the first element removed. |
====Map==== | ====Map==== |
Revision as of 22:59, 4 November 2011
Contents |
Introduction
The STL (Standard Template Library) in C++ is a large library consisting of a variety of standard data structures and functions that you might expect to use in all kinds of programming tasks. We have provided a standard interface to access a subset of the Containers implemented in the STL.
The STL Containers are similar to arrays in that they store collections of data. Unlike arrays though, they dynamically grow and shrink as needed.
Initialization
Containers are defined with a similar syntax to formats, with a few added options.
General Usage
Once initialized, there is a standard set of functions that provide access to the STL containers. In general, there are functions that store and access data in the containers, and there are also functions to iterate over and read data from the containers.
Container Types
The following containers have been implemented in Comet32.
Vector
Vectors are dynamic, indexable containers. Basically, they are arrays, but more robust. Like all containers, Vectors will expand and contract automatically when necessary.
List
Lists are sequence containers that are designed for efficient iteration. They provide access to the front and the back of the list, and are doubly-linked which means you can iterate efficiently both backwards and forwards.
Stack
Stacks are lists designed with LIFO (Last In, First Out) access. That is, the last element you add to the stack will be the first element removed.
Queue
Queues are lists designed with FIFO (First In, First Out) access. That is, the first element you added to the stack will be the first element removed.
Map
Maps are associative arrays keyed by string indexes. Basically, a map is a vector that uses a string index instead of a numerical index.