修改push,使得能够循环push元素进入circular buffer中

This commit is contained in:
邹晓航
2014-09-24 15:58:12 +08:00
parent 771aef80aa
commit 3e54fa5144

View File

@@ -190,11 +190,18 @@ namespace TinySTL{
//************<2A><><EFBFBD>룬ɾ<EBA3AC><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>***********************
template<class T, size_t N, class Alloc>
void circular_buffer<T, N, Alloc>::push(const T& val){
if (full())
/*if (full())
throw;
indexOfTail = nextIndex(indexOfTail);
dataAllocator::construct(start_ + indexOfTail, val);
++size_;
*/
if (full()){
indexOfTail = nextIndex(indexOfTail);
dataAllocator::construct(start_ + indexOfTail, val);
indexOfHead = nextIndex(indexOfHead);
}else{
indexOfTail = nextIndex(indexOfTail);
dataAllocator::construct(start_ + indexOfTail, val);
++size_;
}
}
template<class T, size_t N, class Alloc>
void circular_buffer<T, N, Alloc>::pop(){