Gets a copy of the array with an entry inserted.

@param a The input array.
@param idx The position at which to insert.
@param val The value to insert.
@return A new array with the inserted value.
769024
public static long[] insertEntry(long[] a, int idx, long val) {
        long[] b = new long[a.length + 1];
        for (int i = 0; i < b.length; i++) {
            if (i < idx) {
                b[i] = a[i];
            } else if (i == idx) {
                b[idx] = val;
            } else {
                b[i] = a[i - 1];
            }
        }
        return b;
    }
452540
@Override
    @SuppressWarnings("unchecked")
    public <E> E[] toArray(E[] a) {

        if (a.length < size()) {
            a = (E[]) Array.newInstance(a.getClass().getComponentType(), size());
        }

        int aIndex = 0;
        synchronized (this) {

            synchronized (lock) {
                //First add anything in the expedited buffer
                //Check if we wrap around the end of the array before iterating
                if (expeditedPutIndex > expeditedTakeIndex) {
                    for (int i = expeditedTakeIndex; i <= expeditedPutIndex; i++) {
                        a[aIndex] = (E) expeditedBuffer[i];
                        aIndex++;
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = expeditedTakeIndex; i < expeditedBuffer.length; i++) {
                        a[aIndex] = (E) expeditedBuffer[i];
                        aIndex++;
                    }
                    for (int i = 0; i < expeditedPutIndex; i++) {
                        a[aIndex] = (E) expeditedBuffer[i];
                        aIndex++;
                    }
                }

                //Now add the items in the main buffer
                //Check if we wrap around the end of the array before iterating
                if (putIndex > takeIndex) {
                    for (int i = takeIndex; i <= putIndex; i++) {
                        a[aIndex] = (E) buffer[i];
                        aIndex++;
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = takeIndex; i < buffer.length; i++) {
                        a[aIndex] = (E) buffer[i];
                        aIndex++;
                    }
                    for (int i = 0; i < putIndex; i++) {
                        a[aIndex] = (E) buffer[i];
                        aIndex++;
                    }
                }
            }
        }

        if (a.length > size()) {
            a[size()] = null;
        }
        return a;
    }
367225
public static boolean zArrayGet(boolean[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
586214
@SuppressWarnings("unchecked")
	public static <T> T[] insert(T[] buffer, int index, T... newElements) {
		return (T[]) insert((Object)buffer, index, newElements);
	}
316244
public void multiplyValue(int idx, double val) {
        values[idx] = s.times(values[idx], val); 
    }
350901
@NonNull
    @Override
    public MutableArray insertDate(int index, Date value) {
        return insertValue(index, value);
    }
1078826
@SafeVarargs
    public static Integer[] box(final int... a) {
        if (a == null) {
            return null;
        }

        return box(a, 0, a.length);
    }
965377
protected final synchronized byte[] objectToArray(Object val) throws IOException {
        final ByteArrayOutputStream bos = new InitiallyReusableByteArrayOutputStream(getReusableByteBuffer());
        final ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(val);

        return bos.toByteArray();
    }
826045
@Override
    public double getValue(int idx) {
        int vSize = MVecArray.count(varBeliefs);
        if (idx < vSize) {
            return MVecArray.getValue(idx, varBeliefs);
        } else {
            return MVecArray.getValue(idx - vSize, facBeliefs);
        }
    }
368985
public static String[] add(final String[] a, final String element) {
        if (N.isNullOrEmpty(a)) {
            return N.asArray(element);
        }

        final String[] newArray = new String[a.length + 1];

        copy(a, 0, newArray, 0, a.length);
        newArray[a.length] = element;

        return newArray;
    }
740674
function(index, value) {
        var idx_name = ydn.db.base.PREFIX_MULTIENTRY +
            table.getName() + ':' + index.getName();
        var idx_sql = insert_statement + goog.string.quote(idx_name) + ' (' +
            table.getSQLKeyColumnNameQuoted() + ', ' +
            index.getSQLIndexColumnNameQuoted() + ') VALUES (?, ?)';
        var idx_params = [ydn.db.schema.Index.js2sql(key, table.getType()),
              ydn.db.schema.Index.js2sql(value, index.getType())];

        /**
         * @param {SQLTransaction} tx transaction.
         * @param {SQLResultSet} rs results.
         */
        var idx_success = function(tx, rs) {

        };
        /**
         * @param {SQLTransaction} tr transaction.
         * @param {SQLError} error error.
         * @return {boolean} true to roll back.
         */
        var idx_error = function(tr, error) {
          goog.log.warning(me.logger, 'multiEntry index insert error: ' + error.message);
          return false;
        };

        goog.log.finest(me.logger, req.getLabel() + ' multiEntry ' + idx_sql +
            ' ' + idx_params);
        tx.executeSql(idx_sql, idx_params, idx_success, idx_error);
      }
232901
protected static Object primitiveArrayGet(Object self, int idx) {
        return Array.get(self, normaliseIndex(idx, Array.getLength(self)));
    }
203789
public static double[][] array_clone(double[][] a) {
        if(a == null) {
            return a;
        }
        double[][] copy = new double[a.length][];
        for(int i=0;i<a.length;i++) {
            copy[i] = Arrays.copyOf(a[i], a[i].length);
        }
        return copy;
    }
1336329
public Binder insert(int index, Class<?> type, Object value) {
        return new Binder(this, new Insert(index, new Class[]{type}, value));
    }
645661
@NonNull
    @Override
    public MutableArray insertString(int index, String value) {
        return insertValue(index, value);
    }
527102
function(index, valObj, clone) {
            var current = this.jsonQ_current;
            //return if incorrect index is given
            if (isNaN(index) && index != "first" && index != "last") {
                error(index + 'is not a valid index.');
                return this;
            }

            for (var i = 0, ln = current.length; i < ln; i++) {
                var pathC = current[i].path.concat([]),
                    lastKey = pathC.pop(),
                    parRef = this.pathValue(pathC),
                    type = objType(parRef[lastKey]),
                    objLn = parRef[lastKey].length;


                //to limit index
                var idx = index < 0 || index == "first" ? 0 : index > objLn || index == "last" ? objLn : index;


                //if array push
                if (type == 'array') {
                    valObj = clone ? jsonQ.clone(valObj) : valObj;

                    parRef[lastKey].splice(idx, 0, valObj);
                }

                //if string concatenate , if number add
                else if (type == 'string') {
                    var str = parRef[lastKey];
                    parRef[lastKey] = str.substring(0, idx) + valObj + str.substring(idx, objLn);
                }


            }
            return this;

        }
165091
void copyValue(int[] val) {
        int len = val.length;
        if (value.length < len)
            value = new int[len];
        System.arraycopy(val, 0, value, 0, len);
        intLen = len;
        offset = 0;
    }