Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103283
  • 博文数量: 18
  • 博客积分: 1425
  • 博客等级: 上尉
  • 技术积分: 236
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-21 20:38
文章分类
文章存档

2011年(6)

2009年(10)

2008年(2)

我的朋友

分类: C/C++

2009-04-02 10:18:53

I think there are some key parts for the project according to the ideas about the devecotr.

1. The design of iterator

Two iterator interfaces,seg_iter and iterator

iterator:traverse the elements in devector.

set_iter:traverse the segment in devector.

2. Variant sized chunk in devector

Just a few key interfaces are  shown in the iterators declarations.

 template

class __devector_iterator{

public:

void reserve(size_type);

typedef T* iterator;

typedef T* pointer;

T* first,last,cur;

pointer data;

__seg_iterator node;

};

template

class __seg_iterator{

public:

size_type size();//return size of the chunk

T** seg;

};

3. Reserve function

As is said in the project idea, the std::deque has the inability to reserve chunks of memory in advance (at both ends),so  two reserve interfaces are needed for reserving the chunks at both end.

void res_back(size_type ),this function is ued to reserve a number of elments at back chunk.

void res_front(size_type),this function is used to reserve a number of chunks at front chunk.

4.Interfaces in devector

templateclass Ref,class Ptr,size_t ChunkSize=0>

class  devecor{

public:

typedef __seg_iterator seg_iterator;

typedef __devector_iteratorChunkSize> iterator;

seg_iterator segment(iterator);//a interface for transfering the iterator to a seg_iterator.

};

I just list some key details about this project,mor details can be got after discussion with mentor or deveopsers in maillis.


Reference

[1]

[2]

[3]

[4]c++ program language (special edition),2003

[5] The annotated STL sources(using SGI STL) ,2001, JJHou

阅读(1246) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~