aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/ringbuffer.h35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/stable/ringbuffer.h b/src/stable/ringbuffer.h
index d4b5993..79c5a15 100644
--- a/src/stable/ringbuffer.h
+++ b/src/stable/ringbuffer.h
@@ -67,16 +67,15 @@ namespace Bu
67 iStart = 0; 67 iStart = 0;
68 iEnd = 1; 68 iEnd = 1;
69 va.construct( &aData[0], v ); 69 va.construct( &aData[0], v );
70 return;
70 } 71 }
71 else if( iStart == iEnd ) 72 else if( iStart == iEnd )
72 { 73 {
73 throw ExceptionBase("Hey, it's full!"); 74 // The ringbuffer is full
74 } 75 dequeue();
75 else
76 {
77 va.construct( &aData[iEnd], v );
78 iEnd = (iEnd+1)%iCapacity;
79 } 76 }
77 va.construct( &aData[iEnd], v );
78 iEnd = (iEnd+1)%iCapacity;
80 } 79 }
81 80
82 value dequeue() 81 value dequeue()
@@ -104,6 +103,16 @@ namespace Bu
104 return aData[(iIndex+iStart)%iCapacity]; 103 return aData[(iIndex+iStart)%iCapacity];
105 } 104 }
106 105
106 value &first()
107 {
108 return aData[iStart];
109 }
110
111 value &last()
112 {
113 return aData[(iEnd-1+iCapacity)%iCapacity];
114 }
115
107 int getSize() 116 int getSize()
108 { 117 {
109 if( iStart < 0 ) 118 if( iStart < 0 )
@@ -201,6 +210,20 @@ namespace Bu
201 return core->get( 0 ); 210 return core->get( 0 );
202 } 211 }
203 212
213 virtual value &first()
214 {
215 _hardCopy();
216
217 return core->first();
218 }
219
220 virtual value &last()
221 {
222 _hardCopy();
223
224 return core->last();
225 }
226
204 value &operator[]( int iIndex ) 227 value &operator[]( int iIndex )
205 { 228 {
206 _hardCopy(); 229 _hardCopy();