From df6a899ad6c9a1c792582ef1a3b838c7eb6d330c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 3 May 2012 06:30:36 +0000 Subject: Rearranging some stuff. --- src/stable/ringbuffer.h | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/stable') 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 iStart = 0; iEnd = 1; va.construct( &aData[0], v ); + return; } else if( iStart == iEnd ) { - throw ExceptionBase("Hey, it's full!"); - } - else - { - va.construct( &aData[iEnd], v ); - iEnd = (iEnd+1)%iCapacity; + // The ringbuffer is full + dequeue(); } + va.construct( &aData[iEnd], v ); + iEnd = (iEnd+1)%iCapacity; } value dequeue() @@ -104,6 +103,16 @@ namespace Bu return aData[(iIndex+iStart)%iCapacity]; } + value &first() + { + return aData[iStart]; + } + + value &last() + { + return aData[(iEnd-1+iCapacity)%iCapacity]; + } + int getSize() { if( iStart < 0 ) @@ -201,6 +210,20 @@ namespace Bu return core->get( 0 ); } + virtual value &first() + { + _hardCopy(); + + return core->first(); + } + + virtual value &last() + { + _hardCopy(); + + return core->last(); + } + value &operator[]( int iIndex ) { _hardCopy(); -- cgit v1.2.3