|
@@ -30,7 +30,6 @@ const char& circular_buffer::const_iterator::operator*()const {
|
|
return *(source + offset);
|
|
return *(source + offset);
|
|
}
|
|
}
|
|
circular_buffer::iterator& circular_buffer::iterator::operator++(){
|
|
circular_buffer::iterator& circular_buffer::iterator::operator++(){
|
|
- std::cout << period << std::endl;
|
|
|
|
++offset;
|
|
++offset;
|
|
if(offset == period)offset = 0;
|
|
if(offset == period)offset = 0;
|
|
return *this;
|
|
return *this;
|
|
@@ -47,37 +46,24 @@ circular_buffer::const_iterator circular_buffer::const_iterator::operator+(size_
|
|
return circular_buffer::const_iterator(parent, source, period, (offset + leap) % period);
|
|
return circular_buffer::const_iterator(parent, source, period, (offset + leap) % period);
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const iterator& o)const{
|
|
|
|
+ using ui = std::ptrdiff_t;
|
|
assert(source == o.source);
|
|
assert(source == o.source);
|
|
- if(o.offset > offset)
|
|
|
|
- return -(o - *this);
|
|
|
|
- if(o.offset == offset)return 0;
|
|
|
|
- if(parent->m_begin.offset < parent->m_end.offset)
|
|
|
|
- return offset - o.offset;
|
|
|
|
- return (offset - o.offset) % period;
|
|
|
|
|
|
+ ui so = m_begin.offset;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const const_iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::iterator::operator-(const const_iterator& o)const{
|
|
assert(source == o.source);
|
|
assert(source == o.source);
|
|
- if(o.offset > offset)
|
|
|
|
- return -(o - *this);
|
|
|
|
- if(o.offset == offset)return 0;
|
|
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
return offset - o.offset;
|
|
return offset - o.offset;
|
|
return (offset - o.offset) % period;
|
|
return (offset - o.offset) % period;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const iterator& o)const{
|
|
assert(source == o.source);
|
|
assert(source == o.source);
|
|
- if(o.offset > offset)
|
|
|
|
- return -(o - *this);
|
|
|
|
- if(o.offset == offset)return 0;
|
|
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
return offset - o.offset;
|
|
return offset - o.offset;
|
|
return (offset - o.offset) % period;
|
|
return (offset - o.offset) % period;
|
|
}
|
|
}
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const const_iterator& o)const{
|
|
std::ptrdiff_t circular_buffer::const_iterator::operator-(const const_iterator& o)const{
|
|
assert(source == o.source);
|
|
assert(source == o.source);
|
|
- if(o.offset > offset)
|
|
|
|
- return -(o - *this);
|
|
|
|
- if(o.offset == offset)return 0;
|
|
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
if(parent->m_begin.offset < parent->m_end.offset)
|
|
return offset - o.offset;
|
|
return offset - o.offset;
|
|
return (offset - o.offset) % period;
|
|
return (offset - o.offset) % period;
|
|
@@ -93,6 +79,40 @@ circular_buffer::const_iterator& circular_buffer::const_iterator::operator=(cons
|
|
period = o.period;
|
|
period = o.period;
|
|
offset = o.offset;
|
|
offset = o.offset;
|
|
}
|
|
}
|
|
|
|
+bool circular_buffer::iterator::operator!=(const iterator& o){
|
|
|
|
+ return source != o.source || parent != o.parent || period != o.period || offset != o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::iterator::operator!=(const const_iterator& o){
|
|
|
|
+ return source != o.source || parent != o.parent || period != o.period || offset != o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::const_iterator::operator!=(const iterator& o){
|
|
|
|
+ return source != o.source || parent != o.parent || period != o.period || offset != o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::const_iterator::operator!=(const const_iterator& o){
|
|
|
|
+ return source != o.source || parent != o.parent || period != o.period || offset != o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::iterator::operator==(const iterator& o){
|
|
|
|
+ return source == o.source && parent == o.parent && period == o.period && offset == o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::iterator::operator==(const const_iterator& o){
|
|
|
|
+ return source == o.source && parent == o.parent && period == o.period && offset == o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::const_iterator::operator==(const iterator& o){
|
|
|
|
+ return source == o.source && parent == o.parent && period == o.period && offset == o.offset;
|
|
|
|
+}
|
|
|
|
+bool circular_buffer::const_iterator::operator==(const const_iterator& o){
|
|
|
|
+ return source == o.source && parent == o.parent && period == o.period && offset == o.offset;
|
|
|
|
+}
|
|
|
|
+circular_buffer::iterator& circular_buffer::iterator::operator--(){
|
|
|
|
+ if(offset == 0)
|
|
|
|
+ offset = period;
|
|
|
|
+ --offset;
|
|
|
|
+}
|
|
|
|
+circular_buffer::const_iterator& circular_buffer::const_iterator::operator--(){
|
|
|
|
+ if(offset == 0)
|
|
|
|
+ offset = period;
|
|
|
|
+ --offset;
|
|
|
|
+}
|
|
circular_buffer::iterator::operator const_iterator(){
|
|
circular_buffer::iterator::operator const_iterator(){
|
|
return const_iterator(parent, source, period, offset);
|
|
return const_iterator(parent, source, period, offset);
|
|
}
|
|
}
|
|
@@ -108,6 +128,21 @@ circular_buffer::iterator circular_buffer::end(){
|
|
circular_buffer::const_iterator circular_buffer::end()const{
|
|
circular_buffer::const_iterator circular_buffer::end()const{
|
|
return circular_buffer::const_iterator(m_end.parent, m_end.source, m_end.period, m_end.offset);
|
|
return circular_buffer::const_iterator(m_end.parent, m_end.source, m_end.period, m_end.offset);
|
|
}
|
|
}
|
|
|
|
+void circular_buffer::push_front(char c){
|
|
|
|
+ --m_begin;
|
|
|
|
+ *m_begin = c;
|
|
|
|
+}
|
|
|
|
+void circular_buffer::push_back(char c){
|
|
|
|
+ *m_end = c;
|
|
|
|
+ ++m_end;
|
|
|
|
+}
|
|
|
|
+void circular_buffer::pop_front(char c){
|
|
|
|
+ ++m_begin;
|
|
|
|
+}
|
|
|
|
+void circular_buffer::pop_back(char c){
|
|
|
|
+ --m_end;
|
|
|
|
+}
|
|
|
|
+
|
|
socket_ostream& socket_ostream::put(char_type c){
|
|
socket_ostream& socket_ostream::put(char_type c){
|
|
|
|
|
|
}
|
|
}
|