insert value into the sorted array a, at the index returned by java.util.Arrays.binarySearch()
@param a array to add to, may be null
@param value value to add to a
@return new sorted array with value added
518212
public static int[] addToSortedIntArray(int[] a, int value) {
		
		if(a == null || a.length == 0) {
			return new int[] {value};
		}
		
		int insertionPoint = -java.util.Arrays.binarySearch(a, value) - 1;
		if(insertionPoint < 0) {
			throw new IllegalArgumentException(String.format("Element %d already exists in array", value));
		}
		
		int[] array = new int[a.length + 1];
		if(insertionPoint > 0) {
			System.arraycopy(a, 0, array, 0, insertionPoint);
		}
		array[insertionPoint] = value;
		if(insertionPoint < a.length) {
			System.arraycopy(a, insertionPoint, array, insertionPoint + 1, array.length - insertionPoint - 1);
		}
		
		return array;
	}
167496
protected void insertNewKeyValueAt(int i, short key, Container value) {
    extendArray(1);
    System.arraycopy(keys, i, keys, i + 1, size - i);
    keys[i] = key;
    System.arraycopy(values, i, values, i + 1, size - i);
    values[i] = value;
    size++;
  }
1344403
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
        this.put(index, new JSONObject(value));
        return this;
    }
1208975
public void add(Value value) {
	if (values == null) values = new LinkedList();
	values.add(value);
    }
307213
public void insert(StringBuilder buffer, Object value, int index) {
        if (buffer == null) {
            throw new NullPointerException("buffer");
        }

        buffer.insert(index, value);
    }
276675
public int addValue(Object[] array) {
        int val = hashCode();
        for (Object obj : array) {
            val = addValue(obj);
        }
        return val;
    }
1222082
public JsonArray add(Object value) {
        if (value == this) {
            throw new IllegalArgumentException("Cannot add self");
        } else if (value == JsonValue.NULL) {
            addNull();
        } else if (checkType(value)) {
            content.add(value);
        } else {
            throw new IllegalArgumentException("Unsupported type for JsonArray: " + value.getClass());
        }
        return this;
    }
839037
public static void putDoubleBE(final byte[] array, final int offset, final double value) {
    putLongBE(array, offset, Double.doubleToRawLongBits(value));
  }
1263352
public static int binarySearchValueOrHigher(ListNumber values, double value) {
        if (value <= values.getDouble(0)) {
            return 0;
        }
        if (value >= values.getDouble(values.size() -1)) {
            return values.size() - 1;
        }
        
        int index = binarySearch(0, values.size() - 1, values, value);
        
        while (index != values.size() - 1 && value > values.getDouble(index)) {
            index++;
        }
        
        while (index != values.size() - 1 && value == values.getDouble(index + 1)) {
            index++;
        }
        
        return index;
    }
372152
public void addValue (int value)
    {
        if (value < _minValue) {
            _buckets[0]++;
        } else if (value >= _maxValue) {
            _buckets[_buckets.length-1]++;
        } else {
            _buckets[(value-_minValue)/_bucketWidth]++;
        }
        _count++;
    }
1252348
public static <T extends Object> T[] insert (T[] values, T value, int index)
    {
        @SuppressWarnings("unchecked")
        T[] nvalues = (T[])Array.newInstance(values.getClass().getComponentType(), values.length+1);
        if (index > 0) {
            System.arraycopy(values, 0, nvalues, 0, index);
        }
        nvalues[index] = value;
        if (index < values.length) {
            System.arraycopy(values, index, nvalues, index+1, values.length-index);
        }
        return nvalues;
    }
1065707
@Override
    public void add(int idx, double val) {
        int i = Arrays.binarySearch(indices, 0, used, idx);
        if (i >= 0) {
            // Just add to the existing value.
            values[i] += val;
            return;
        } 
        int insertionPoint = -(i + 1);
        indices = insert(indices, insertionPoint, idx);
        values = insert(values, insertionPoint, val);
        used++;
    }
1164989
public static void fill(final Object[] array, final Object value) {
        //        final int n = array.length;
        //        if (n > 0) {
        //            array[0] = value;
        //        }
        //        for (int i = 1; i < n; i += i) {
        //           System.arraycopy(array, 0, array, i, ((n - i) < i) ? (n - i) : i);
        //        }
        for (int i=0; i<array.length; i++) {
            array[i] = value;
        }        
    }
741770
public void put(byte[] value) {
		if (value == null) {
			this.compiledStatement.bindNull(compiledStatementBindIndex++);
		} else {
			compiledStatement.bindBlob(compiledStatementBindIndex++, value);
		}
	}
1124559
public int addValue(boolean[] array) {
        int val = hashCode();
        for (boolean b : array) {
            val = addValue(b);
        }
        return val;
    }
1294998
public void add(long value) {
		int index = Arrays.binarySearch(bins, value);
		if (index < 0) {
			// inexact match, take the first bin higher than value
			index = -index - 1;
		}
		hits.incrementAndGet(index);
	}
864251
public StrBuilder insert(int index, final boolean value) {
        validateIndex(index);
        if (value) {
            ensureCapacity(size + 4);
            System.arraycopy(buffer, index, buffer, index + 4, size - index);
            buffer[index++] = 't';
            buffer[index++] = 'r';
            buffer[index++] = 'u';
            buffer[index] = 'e';
            size += 4;
        } else {
            ensureCapacity(size + 5);
            System.arraycopy(buffer, index, buffer, index + 5, size - index);
            buffer[index++] = 'f';
            buffer[index++] = 'a';
            buffer[index++] = 'l';
            buffer[index++] = 's';
            buffer[index] = 'e';
            size += 5;
        }
        return this;
    }