/**
 * Company
 * Copyright (C) 2014-2017 All Rights Reserved.
 */
package com.cwenao.trying;

/**
 * @author cwenao
 * @version $Id OperationArray.java, v 0.1 2017-07-11 8:24 cwenao Exp $$
 */
public class OperationArray<E> {

    public int searchOnUnSortArray(E[] array, int len, E key) {
        for (int i =0;i<len;i++) {
            if (array[i] == key) {
                return  i;
            }
        }
        return -1;
    }


    public int insertOnUnSortArray(E[] array, int len, int index,E key) {
        if (index > len - 1) {
            return -1;
        }

        array[index] = key;

        return index + 1;
    }

    public void deleteOnUnSortArray(E[] array, int index,int len) {
        for (int i = index; i < len - 1; i++) {
            array[i] = array[i + 1];
        }
    }

    public static void main(String[] args) {
        OperationArray<Integer> operationArray = new OperationArray<>();
        Integer[] array = {1, 2, 3, 5, 4, 6, 7, 8};
        int len = array.length;

        System.out.println(operationArray.searchOnUnSortArray(array, len, 3));

        operationArray.insertOnUnSortArray(array, len, 4, 100);

        System.out.println(operationArray.searchOnUnSortArray(array, len, 100));

        operationArray.deleteOnUnSortArray(array, 4, len);

        System.out.println(operationArray.searchOnUnSortArray(array, len, 100));

    }

}


@@ -796,32 +796,467 @@
        %7D%0A    %7D%0A%0A
+    public int serachOnSortArray(int%5B%5D array, int low, int high, int key) %7B%0A        if (high %3C low) %7B%0A            return -1;%0A        %7D%0A%0A        int mid = (low + high) / 2;%0A        if (array%5Bmid%5D == key) %7B%0A            return mid;%0A        %7D%0A        if (array%5Bmid%5D %3C key) %7B%0A            return serachOnSortArray(array, mid + 1, high, key);%0A        %7D else %7B%0A            return serachOnSortArray(array, low, mid - 1, key);%0A        %7D%0A    %7D%0A%0A%0A
     public stati
@@ -1807,22 +1807,268 @@
 en, 100));%0A%0A
+        int%5B%5D sortedArray = %7B1, 2, 3, 4, 5, 6, 7, 8, 9%7D;%0A        int sortedLen = sortedArray.length;%0A        int low = 0;%0A        int high = sortedLen - 1;%0A        System.out.println(operationArray.serachOnSortArray(sortedArray, low, high, 3));%0A%0A
     %7D%0A%0A%7D%0A%0A

update the operation search for sortedArray