ArrayUtility.java
Go to the documentation of this file.
1 
12 public class ArrayUtility
13 {
19  public static int[] addElement(int[] current, int elem)
20  {
21  int[] to_return = new int[current.length+1];
22  for(int i=0; i<current.length; i++)
23  to_return[i]=current[i];
24  to_return[to_return.length-1]=elem;
25  return to_return;
26  }
27 
33  public static int[] deleteElement(int[] current, int index)
34  {
35  int[] to_return = new int[current.length-1];
36  for(int i=0,j=0; i<current.length; i++,j++)
37  if(i==index)
38  j--;
39  else
40  to_return[j] = current[i];
41  return to_return;
42  }
43 
50  public static int linearSearch(int[] current, int value)
51  {
52  for(int i=0; i<current.length; i++)
53  if(current[i]==value)
54  return i;
55  return -1;
56  }
57 }
static int[] addElement(int[] current, int elem)
static int linearSearch(int[] current, int value)
static int[] deleteElement(int[] current, int index)