public int addStatementGetIndex(String statementName){
  rwLock.acquireWriteLock();
  try {
    if ((currentLastElement + 1) < metrics.length) {
      currentLastElement++;
      statementNames[currentLastElement]=statementName;
      return currentLastElement;
    }
    for (int i=0; i < statementNames.length; i++) {
      if (statementNames[i] == null) {
        statementNames[i]=statementName;
        if ((i + 1) > currentLastElement) {
          currentLastElement=i;
        }
        return i;
      }
    }
    int newSize=(int)(metrics.length * 1.5);
    String[] newStatementNames=new String[newSize];
    StatementMetric[] newMetrics=new StatementMetric[newSize];
    System.arraycopy(statementNames,0,newStatementNames,0,statementNames.length);
    System.arraycopy(metrics,0,newMetrics,0,metrics.length);
    statementNames=newStatementNames;
    metrics=newMetrics;
    currentLastElement++;
    statementNames[currentLastElement]=statementName;
    return currentLastElement;
  }
  finally {
    rwLock.releaseWriteLock();
  }
}

public int addStatementGetIndex ( String statementName ) { rwLock . acquireWriteLock ( ) ; try { if ( ( currentLastElement + 1 ) < metrics . length ) { currentLastElement ++ ; statementNames [ currentLastElement ] = statementName ; return currentLastElement ; } for ( int i = 0 ; i < statementNames . length ; i ++ ) { if ( statementNames [ i ] == null ) { statementNames [ i ] = statementName ; if ( ( i + 1 ) > currentLastElement ) { currentLastElement = i ; } return i ; } } int newSize = ( int ) ( metrics . length * 1.5 ) ; String [ ] newStatementNames = new String [ newSize ] ; StatementMetric [ ] newMetrics = new StatementMetric [ newSize ] ; System . arraycopy ( statementNames , 0 , newStatementNames , 0 , statementNames . length ) ; System . arraycopy ( metrics , 0 , newMetrics , 0 , metrics . length ) ; statementNames = newStatementNames ; metrics = newMetrics ; currentLastElement ++ ; statementNames [ currentLastElement ] = statementName ; return currentLastElement ; } finally { rwLock . releaseWriteLock ( ) ; } }
adds a statement and returns the index added at . < p > may reuse an empty slot , grow the underlying array , or append to the end .
