Mike, it's a very clean and efficient remove:
it memmoves the data 1 bank over until the original head is reached, then the head is incremented, available decreases, and exits
Code:
template<typename T, uint16_t _size, uint16_t multi>
bool Circular_Buffer<T,_size,multi>::remove(uint16_t pos) {
if ( multi ) {
if ( pos >= _size ) return 0;
uint16_t find_area = 0;
for ( uint16_t i = 0; i < _size; i++ ) {
if ( ((head+i)&(_size-1)) == pos ) {
find_area = i;
break;
}
}
while ( ((head+find_area)&(_size-1)) != ((head)&(_size-1)) ) {
memmove(_cabuf[_cbuf[((head+find_area)&(_size-1))]]+2,_cabuf[_cbuf[((head+find_area-1)&(_size-1))]]+2,((int)((int)_cabuf[(int)_cbuf[(head+find_area-1)&(_size-1)]][0] << 8*sizeof(T)) | (int)_cabuf[(int)_cbuf[(head+find_area-1)&(_size-1)]][1])+1);
find_area--;
}
head = ((head + 1)&(2*_size-1));
_available--;
return 1;
}
return 0;
}
it memmoves the data 1 bank over until the original head is reached, then the head is incremented, available decreases, and exits