分类: 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
};
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
template
class devecor{
public:
typedef __seg_iterator
typedef __devector_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.
[1]
[2]
[3]
[4]c++ program language (special edition),2003
[5] The annotated STL sources(using SGI STL) ,2001, JJHou