修改push,使得能够循环push元素进入circular buffer中
This commit is contained in:
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user