java.lang.System#arraycopy ( )源码实例Demo

下面列出了java.lang.System#arraycopy ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AliceBot   文件: Category.java
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;
}
 
源代码2 项目: AliceBot   文件: Category.java
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;
}
 
源代码3 项目: Rholang   文件: Main.java
/***************************************************************
   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;
  }
     }
 
源代码4 项目: mollyim-android   文件: ArrayListCursor.java
@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);
        }
    }
}
 
源代码5 项目: bcm-android   文件: ArrayListCursor.java
@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);
        }
    }
}
 
源代码6 项目: AliceBot   文件: Pattern.java
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;
  }
}
 
源代码7 项目: Rholang   文件: Main.java
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);
   }
 
源代码8 项目: Rholang   文件: Main.java
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++;
   }
 
源代码9 项目: Silence   文件: ArrayListCursor.java
@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);
        }
    }
}
 
源代码10 项目: Rholang   文件: Main.java
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;
   }
 
源代码11 项目: Silence   文件: DecryptingPartInputStream.java
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);
  }
}
 
源代码12 项目: tweetnacl-java   文件: TweetNaclFast.java
public static byte[] randombytes(byte [] x, int len) {
   byte [] b = randombytes(len);
   System.arraycopy(b, 0, x, 0, len);
   return x;
}