001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.adaptive.database.methodsamples;
014    
015    import org.jikesrvm.VM;
016    import org.jikesrvm.compilers.common.CompiledMethod;
017    
018    /**
019     * Wrapper around a pair of parallel arrays:
020     * <ol>
021     *  <li>an array of compiled method id's
022     *  <li>an array of counts: how many times each compiled method id is counted
023     * </ol>
024     */
025    public final class MethodCountSet {
026      /**
027       * array of compiled methods
028       */
029      CompiledMethod[] cms;
030      /**
031       * array of counts
032       */
033      double[] counters;
034    
035      /**
036       * Constructor
037       *
038       * @param _cms array of compiled method ids
039       * @param _counters array of counters
040       */
041      MethodCountSet(CompiledMethod[] _cms, double[] _counters) {
042        if (VM.VerifyAssertions) VM._assert(_cms.length == _counters.length);
043        cms = _cms;
044        counters = _counters;
045      }
046    
047      /**
048       * String representation of fields
049       *
050       * @return string representation of compiled method id's and their counts
051       */
052      @Override
053      public String toString() {
054        String ans = "";
055        for (int i = 0; i < cms.length; i++) {
056          ans += cms[i] + " = " + counters[i] + "\n";
057        }
058        return ans;
059      }
060    }