Browse Source

add clear()

David Rose 21 years ago
parent
commit
6cc498ed97
2 changed files with 13 additions and 0 deletions
  1. 11 0
      panda/src/express/circBuffer.I
  2. 2 0
      panda/src/express/circBuffer.h

+ 11 - 0
panda/src/express/circBuffer.I

@@ -217,3 +217,14 @@ push_back(const Thing &t) {
     _in = (_in+1)%(max_size+1);
     _in = (_in+1)%(max_size+1);
   }
   }
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: CircBuffer::clear
+//       Access: Public
+//  Description: Removes all items from the queue.
+////////////////////////////////////////////////////////////////////
+template<class Thing, int max_size>
+INLINE void CircBuffer<Thing, max_size>::
+clear() {
+  _in = _out = 0;
+}

+ 2 - 0
panda/src/express/circBuffer.h

@@ -60,6 +60,8 @@ public:
   INLINE Thing &back();
   INLINE Thing &back();
   INLINE void push_back(const Thing &t);
   INLINE void push_back(const Thing &t);
 
 
+  INLINE void clear();
+
 private:
 private:
   Thing _array[max_size+1];
   Thing _array[max_size+1];
   int _in, _out;
   int _in, _out;