泛型编程与STL之 container

General Container Concepts

iterator: inputIterator

   Assignable

X::value_type

X::reference

X::pointer

 

X::const_reference

X::const_pointer

X::iterator

X::const_iterator

X::difference_type (int)

X::size_type (unsigned int)

The difference between size and area;

size is the element count of the container

area means how many byte the container occupied.

 

 

The basic function of a general container

begin()

end()

size()

max_size()

empty()

swap()

**************************************************

*****************************************************

**************************************************

Forward container

have certain order. so it allow multi-iterators are active

So, it is: Container, Equality comparable, LessThan Comparable.

When refer to the equality and not Equality, it need Equality Comparable Concept

for others like >=, <=, >, <,  LessThan comparable is just fine.

 

Following is the Forward Container in STL

vector

list

slist

deque

set

hash_set

map

hash_map

multiset

hash_multiset

multimap

hash_multimap

 

**************************************************

*****************************************************

**************************************************

Reversible Container

Bidirectional iterator.

 

 

Usable function:

rbegin()

rend()

 

Model:

vector<double>

list<string>

set<int>

 

**************************************************

*****************************************************

**************************************************

Random Access container

It doesn't contain List, slist.

 

**************************************************

*****************************************************

**************************************************

 

**************************************************

*****************************************************

**************************************************

Sequence

strict linear order.

Forward Container

 

 

Functions:

Fill constructor:

X(n, t) fill container with t, n times.

X(n) equal to X(n, T())

Range constructor:

X(i, j) fill the container with the elements between iterator i and j

Insert:

a.insert(p, t) insert t before the iterator p of container a. p would be 

invalid sometimes, it depends the container.

Fill Insert:

a.insert(p, n, t)

Range Insert:

a.insert(p, i, j)

Erase:

a.erase(p), return the next element of p or end if p is the last element

Range erase:

a.erase(p, q)

Front:

a.front(), if a is mutable, return iterator, or const_iterator.

**************************************************

*****************************************************

**************************************************

Front Insert Sequence

Functions:

Front:

a.front()

Push_front:

a.push_front(p)

Pop_front:

a.pop_front(); return void!!

Page:144

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值