Java Code Examples for java.lang.System#arraycopy()
The following examples show how to use
java.lang.System#arraycopy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Category.java From AliceBot with Apache License 2.0 | 6 votes |
public String[] getMatchPath() { String[] pattPath = pattern.getElements(); String[] thatPath = that.elements(); String[] topicPath = topic.elements(); int m = pattPath.length; int n = thatPath.length; int o = topicPath.length; String[] matchPath = new String[m + 1 + n + 1 + o]; matchPath[m] = "<THAT>"; matchPath[m + 1 + n] = "<TOPIC>"; //注意这里path的顺序 System.arraycopy(pattPath, 0, matchPath, 0, m); System.arraycopy(thatPath, 0, matchPath, m + 1, n); System.arraycopy(topicPath, 0, matchPath, m + 1 + n + 1, o); return matchPath; }
Example 2
Source File: Category.java From AliceBot with Apache License 2.0 | 6 votes |
public String[] getMatchPath() { String[] pattPath = pattern.getElements(); String[] thatPath = that.elements(); String[] topicPath = topic.elements(); int m = pattPath.length; int n = thatPath.length; int o = topicPath.length; String[] matchPath = new String[m + 1 + n + 1 + o]; matchPath[m] = "<THAT>"; matchPath[m + 1 + n] = "<TOPIC>"; System.arraycopy(pattPath, 0, matchPath, 0, m); System.arraycopy(thatPath, 0, matchPath, m + 1, n); System.arraycopy(topicPath, 0, matchPath, m + 1 + n + 1, o); return matchPath; }
Example 3
Source File: Main.java From Rholang with MIT License | 6 votes |
/*************************************************************** Function: trunc_col Description: Truncates each column to the 'correct' length. **************************************************************/ private void trunc_col ( ) { int n; int i; CDTrans dtrans; n = m_spec.m_dtrans_vector.size(); for (i = 0; i < n; ++i) { int[] ndtrans = new int[m_spec.m_dtrans_ncols]; dtrans = (CDTrans) m_spec.m_dtrans_vector.elementAt(i); System.arraycopy(dtrans.m_dtrans, 0, ndtrans, 0, ndtrans.length); dtrans.m_dtrans = ndtrans; } }
Example 4
Source File: ArrayListCursor.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"unchecked"}) public ArrayListCursor(String[] columnNames, ArrayList<ArrayList> rows) { int colCount = columnNames.length; boolean foundID = false; // Add an _id column if not in columnNames for (int i = 0; i < colCount; ++i) { if (columnNames[i].compareToIgnoreCase("_id") == 0) { mColumnNames = columnNames; foundID = true; break; } } if (!foundID) { mColumnNames = new String[colCount + 1]; System.arraycopy(columnNames, 0, mColumnNames, 0, columnNames.length); mColumnNames[colCount] = "_id"; } int rowCount = rows.size(); mRows = new ArrayList[rowCount]; for (int i = 0; i < rowCount; ++i) { mRows[i] = rows.get(i); if (!foundID) { mRows[i].add(i); } } }
Example 5
Source File: ArrayListCursor.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"unchecked"}) public ArrayListCursor(String[] columnNames, ArrayList<ArrayList> rows) { int colCount = columnNames.length; boolean foundID = false; // Add an _id column if not in columnNames for (int i = 0; i < colCount; ++i) { if (columnNames[i].compareToIgnoreCase("_id") == 0) { mColumnNames = columnNames; foundID = true; break; } } if (!foundID) { mColumnNames = new String[colCount + 1]; System.arraycopy(columnNames, 0, mColumnNames, 0, columnNames.length); mColumnNames[colCount] = "_id"; } int rowCount = rows.size(); mRows = new ArrayList[rowCount]; for (int i = 0; i < rowCount; ++i) { mRows[i] = rows.get(i); if (!foundID) { mRows[i].add(i); } } }
Example 6
Source File: Pattern.java From AliceBot with Apache License 2.0 | 5 votes |
public void appendChild(AIMLElement child) { String text = child.toString(); if (pattern == null) pattern = new String[] {text}; else { int length = pattern.length; String[] larger = new String[length + 1]; System.arraycopy(pattern, 0, larger, 0, length); larger[length] = text; pattern = larger; } }
Example 7
Source File: Main.java From Rholang with MIT License | 5 votes |
private void new_block(int idx, int bnum) { if (size==bits.length) { // resize long[] nbits = new long[size*3]; int [] noffs = new int [size*3]; System.arraycopy(bits, 0, nbits, 0, size); System.arraycopy(offs, 0, noffs, 0, size); bits = nbits; offs = noffs; } CUtility.ASSERT(size<bits.length); insert_block(idx, bnum); }
Example 8
Source File: Main.java From Rholang with MIT License | 5 votes |
private void insert_block(int idx, int bnum) { CUtility.ASSERT(idx<=size); CUtility.ASSERT(idx==size || offs[idx]!=bnum); System.arraycopy(bits, idx, bits, idx+1, size-idx); System.arraycopy(offs, idx, offs, idx+1, size-idx); offs[idx]=bnum; bits[idx]=0; //clear them bits. size++; }
Example 9
Source File: ArrayListCursor.java From Silence with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings({"unchecked"}) public ArrayListCursor(String[] columnNames, ArrayList<ArrayList> rows) { int colCount = columnNames.length; boolean foundID = false; // Add an _id column if not in columnNames for (String columnName : columnNames) { if (columnName.compareToIgnoreCase("_id") == 0) { mColumnNames = columnNames; foundID = true; break; } } if (!foundID) { mColumnNames = new String[colCount + 1]; System.arraycopy(columnNames, 0, mColumnNames, 0, columnNames.length); mColumnNames[colCount] = "_id"; } int rowCount = rows.size(); mRows = new ArrayList[rowCount]; for (int i = 0; i < rowCount; ++i) { mRows[i] = rows.get(i); if (!foundID) { mRows[i].add(i); } } }
Example 10
Source File: Main.java From Rholang with MIT License | 4 votes |
private static final void binop(SparseBitSet a, SparseBitSet b, BinOp op) { int nsize = a.size + b.size; long[] nbits; int [] noffs; int a_zero, a_size; // be very clever and avoid allocating more memory if we can. if (a.bits.length < nsize) { // oh well, have to make working space. nbits = new long[nsize]; noffs = new int [nsize]; a_zero = 0; a_size = a.size; } else { // reduce, reuse, recycle! nbits = a.bits; noffs = a.offs; a_zero = a.bits.length - a.size; a_size = a.bits.length; System.arraycopy(a.bits, 0, a.bits, a_zero, a.size); System.arraycopy(a.offs, 0, a.offs, a_zero, a.size); } // ok, crunch through and binop those sets! nsize = 0; for (int i=a_zero, j=0; i<a_size || j<b.size; ) { long nb; int no; if (i<a_size && (j>=b.size || a.offs[i] < b.offs[j])) { nb = op.op(a.bits[i], 0); no = a.offs[i]; i++; } else if (j<b.size && (i>=a_size || a.offs[i] > b.offs[j])) { nb = op.op(0, b.bits[j]); no = b.offs[j]; j++; } else { // equal keys; merge. nb = op.op(a.bits[i], b.bits[j]); no = a.offs[i]; i++; j++; } if (nb!=0) { nbits[nsize] = nb; noffs[nsize] = no; nsize++; } } a.bits = nbits; a.offs = noffs; a.size = nsize; }
Example 11
Source File: DecryptingPartInputStream.java From Silence with GNU General Public License v3.0 | 4 votes |
private int readIncremental(byte[] buffer, int offset, int length) throws IOException { int readLength = 0; if (null != overflowBuffer) { if (overflowBuffer.length > length) { System.arraycopy(overflowBuffer, 0, buffer, offset, length); overflowBuffer = Arrays.copyOfRange(overflowBuffer, length, overflowBuffer.length); return length; } else if (overflowBuffer.length == length) { System.arraycopy(overflowBuffer, 0, buffer, offset, length); overflowBuffer = null; return length; } else { System.arraycopy(overflowBuffer, 0, buffer, offset, overflowBuffer.length); readLength += overflowBuffer.length; offset += readLength; length -= readLength; overflowBuffer = null; } } if (length + totalRead > totalDataSize) length = (int)(totalDataSize - totalRead); byte[] internalBuffer = new byte[length]; int read = super.read(internalBuffer, 0, internalBuffer.length <= cipher.getBlockSize() ? internalBuffer.length : internalBuffer.length - cipher.getBlockSize()); totalRead += read; try { mac.update(internalBuffer, 0, read); digest.update(internalBuffer, 0, read); int outputLen = cipher.getOutputSize(read); if (outputLen <= length) { readLength += cipher.update(internalBuffer, 0, read, buffer, offset); return readLength; } byte[] transientBuffer = new byte[outputLen]; outputLen = cipher.update(internalBuffer, 0, read, transientBuffer, 0); if (outputLen <= length) { System.arraycopy(transientBuffer, 0, buffer, offset, outputLen); readLength += outputLen; } else { System.arraycopy(transientBuffer, 0, buffer, offset, length); overflowBuffer = Arrays.copyOfRange(transientBuffer, length, outputLen); readLength += length; } return readLength; } catch (ShortBufferException e) { throw new AssertionError(e); } }
Example 12
Source File: TweetNaclFast.java From tweetnacl-java with MIT License | 4 votes |
public static byte[] randombytes(byte [] x, int len) { byte [] b = randombytes(len); System.arraycopy(b, 0, x, 0, len); return x; }