1 21 package com.db4o.db4ounit.common.foundation; 22 23 import com.db4o.foundation.*; 24 25 public class IntArrays4 { 26 27 public static int[] fill(int[] array, int value) { 28 for (int i=0; i<array.length; ++i) { 29 array[i] = value; 30 } 31 return array; 32 } 33 34 public static int[] concat(int[] a, int[] b) { 35 int[] array = new int[a.length + b.length]; 36 System.arraycopy(a, 0, array, 0, a.length); 37 System.arraycopy(b, 0, array, a.length, b.length); 38 return array; 39 } 40 41 public static int occurences(int[] values, int value) { 42 int count = 0; 43 for (int i = 0; i < values.length; i++) { 44 if(values[i] == value){ 45 count ++; 46 } 47 } 48 return count; 49 } 50 51 public static int[] clone(int[] bars) { 52 int[] array = new int[bars.length]; 53 System.arraycopy(bars, 0, array, 0, bars.length); 54 return array; 55 } 56 57 public static Object [] toObjectArray(int[] values) { 58 Object [] ret = new Object [values.length]; 59 for (int i = 0; i < values.length; i++) { 60 ret[i] = new Integer (values[i]); 61 } 62 return ret; 63 } 64 65 public static Iterator4 newIterator(int[] values) { 66 return new ArrayIterator4(toObjectArray(values)); 67 } 68 69 } 70 | Popular Tags |