[logback-dev] svn commit: r1387 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers

noreply.seb at qos.ch noreply.seb at qos.ch
Mon Mar 5 10:56:59 CET 2007


Author: seb
Date: Mon Mar  5 10:56:58 2007
New Revision: 1387

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java

Log:
Added a clear method to the CyclicBuffer 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/helpers/CyclicBuffer.java	Mon Mar  5 10:56:58 2007
@@ -43,12 +43,24 @@
       throw new IllegalArgumentException("The maxSize argument (" + maxSize
           + ") is not a positive integer.");
     }
+    init(maxSize);
+  }
+  
+  private void init(int maxSize) {
     this.maxSize = maxSize;
     ea = (E[]) new Object[maxSize];
     first = 0;
     last = 0;
     numElems = 0;
   }
+  
+  /**
+   * Clears the buffer
+   * and resets all attributes.
+   */
+  public void clear() {
+    init(this.maxSize);
+  }
 
   /**
    * Add an <code>event</code> as the last event in the buffer.



More information about the logback-dev mailing list