當前位置: 首頁>>代碼示例>>Java>>正文


Java Arrays.fill方法代碼示例

本文整理匯總了Java中java.util.Arrays.fill方法的典型用法代碼示例。如果您正苦於以下問題:Java Arrays.fill方法的具體用法?Java Arrays.fill怎麽用?Java Arrays.fill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Arrays的用法示例。


在下文中一共展示了Arrays.fill方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setup

import java.util.Arrays; //導入方法依賴的package包/類
@BeforeClass
public static void setup() throws IOException {
  final Configuration conf = new Configuration();
  final FileSystem fs = FileSystem.getLocal(conf).getRaw();
  final Path p = new Path(System.getProperty("test.build.data", "/tmp"),
      "testFileQueue").makeQualified(fs);
  fs.delete(p, true);
  final byte[] b = new byte[BLOCK];
  for (int i = 0; i < NFILES; ++i) {
    Arrays.fill(b, (byte)('A' + i));
    paths[i] = new Path(p, "" + (char)('A' + i));
    OutputStream f = null;
    try {
      f = fs.create(paths[i]);
      f.write(b);
    } finally {
      if (f != null) {
        f.close();
      }
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:TestFileQueue.java

示例2: deliverPermissionResult

import java.util.Arrays; //導入方法依賴的package包/類
private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) {
    // Generate the request results
    int[] requestResults = new int[permissions.length];
    Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED);

    try {
        Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod(
                "onRequestPermissionResult", int.class, String[].class, int[].class);

        onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults);
    } catch (NoSuchMethodException noSuchMethodException) {
        // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it
        // made it to this point
        LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException);
    } catch (IllegalAccessException illegalAccessException) {
        // Should never be caught; this is a public method
        LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException);
    } catch(InvocationTargetException invocationTargetException) {
        // This method may throw a JSONException. We are just duplicating cordova-android's
        // exception handling behavior here; all it does is log the exception in CordovaActivity,
        // print the stacktrace, and ignore it
        LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException);
    }
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:25,代碼來源:PermissionHelper.java

示例3: check

import java.util.Arrays; //導入方法依賴的package包/類
static void check(final int[] array, final int fromIndex,
                  final int toIndex, final int value)
{
    if (DO_CHECKS) {
        // check zero on full array:
        for (int i = 0; i < array.length; i++) {
            if (array[i] != value) {
                logException("Invalid value at: " + i + " = " + array[i]
                        + " from: " + fromIndex + " to: " + toIndex + "\n"
                        + Arrays.toString(array), new Throwable());

                // ensure array is correctly filled:
                Arrays.fill(array, value);

                return;
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:IntArrayCache.java

示例4: getYUV420sp

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * YUV420sp
 *
 * @param inputWidth
 * @param inputHeight
 * @param scaled
 * @return
 */
public static byte[] getYUV420sp(int inputWidth, int inputHeight, Bitmap scaled) {
    int[] argb = new int[inputWidth * inputHeight];

    scaled.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);

    /**
     * 需要轉換成偶數的像素點,否則編碼YUV420的時候有可能導致分配的空間大小不夠而溢出。
     */
    int requiredWidth = inputWidth % 2 == 0 ? inputWidth : inputWidth + 1;
    int requiredHeight = inputHeight % 2 == 0 ? inputHeight : inputHeight + 1;

    int byteLength = requiredWidth * requiredHeight * 3 / 2;
    if (yuvs == null || yuvs.length < byteLength) {
        yuvs = new byte[byteLength];
    } else {
        Arrays.fill(yuvs, (byte) 0);
    }

    encodeYUV420SP(yuvs, argb, inputWidth, inputHeight);

    scaled.recycle();

    return yuvs;
}
 
開發者ID:simplezhli,項目名稱:Tesseract-OCR-Scanner,代碼行數:33,代碼來源:QrUtils.java

示例5: addBump

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Adds a throttle bump at a random location.
 */
public void addBump() {
    Arrays.fill(spedUpSegments, false);
    // increase throttle settings around randomly around some track point
    int center = getNextThrottleBumpPoint();
    int m = (int) (numPoints * getFractionOfTrackToSpeedUp());
    log.info("speeding up " + m + " of " + numPoints + " throttle settings around track point " + center);
    for (int i = 0; i < m; i++) {
        float dist = Math.abs(i - (m / 2));
        float factor = ((m / 2) - dist) / (m / 2);
        int ind = getIndexFrom(center, i);
        throttleValues[ind].throttle = clipThrottle(throttleValues[ind].throttle + (throttleChange * factor)); // increase throttle by tent around random center point
        throttleValues[ind].brake = false;
        spedUpSegments[ind] = true;
    }
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:19,代碼來源:HumanVsComputerThrottleController.java

示例6: resetFilter

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public void resetFilter() {
    if (DavisChip.class.isAssignableFrom(chip.getClass())) {
        apsChip = (DavisChip) chip;
    } else {
        EventFilter.log.warning("The filter ApsFrameExtractor can only be used for chips that extend the ApsDvsChip class");
    }
    newFrame = false;
    width = chip.getSizeX(); // note that on initial construction width=0 because this constructor is called while
    // chip is still being built
    height = chip.getSizeY();
    maxIDX = width * height;
    maxADC = apsChip.getMaxADC();
    apsDisplay.setImageSize(width, height);
    resetBuffer = new float[width * height];
    signalBuffer = new float[width * height];
    displayFrame = new float[width * height];
    displayBuffer = new float[width * height];
    apsDisplayPixmapBuffer = new float[3 * width * height];
    Arrays.fill(resetBuffer, 0.0f);
    Arrays.fill(signalBuffer, 0.0f);
    Arrays.fill(displayFrame, 0.0f);
    Arrays.fill(displayBuffer, 0.0f);
    Arrays.fill(apsDisplayPixmapBuffer, 0.0f);
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:26,代碼來源:ApsFrameExtractor.java

示例7: writeToBuilder

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Write the stack trace to a StringBuilder.
 * @param sb
 *          where to write it
 * @param indent
 *          how many double spaces to indent each line
 */
public void writeToBuilder(final StringBuilder sb, final int indent) {
  // create the indentation string
  final char[] indentation = new char[indent * 2];
  Arrays.fill(indentation, ' ');

  // write the stack trace in standard Java format
  for(StackTraceElement ste : stackTraceElements) {
    sb.append(indentation)
        .append("at ")
        .append(ste.getClassName())
        .append('.')
        .append(ste.getMethodName())
        .append('(')
        .append(ste.getFileName())
        .append(':')
        .append(Integer.toString(ste.getLineNumber()))
        .append(")\n");
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:27,代碼來源:StackTrace.java

示例8: init_encoder

import java.util.Arrays; //導入方法依賴的package包/類
private void init_encoder(int bitsPerPixel) {
	clearCode = 1 << bitsPerPixel;
	endOfImage = clearCode + 1;
	codeLen = bitsPerPixel + 1;
	codeIndex = endOfImage + 1;
	// Reset arrays
	Arrays.fill(child, 0);
	Arrays.fill(siblings, 0);
	Arrays.fill(suffix, 0);
}
 
開發者ID:villeau,項目名稱:pprxmtr,代碼行數:11,代碼來源:AnimatedGIFWriter.java

示例9: createArray

import java.util.Arrays; //導入方法依賴的package包/類
private Integer [] createArray() {
    Integer [] a = new Integer[length];
    Arrays.fill(a, 0);
    int endRun = -1;
    for (long len : runs) {
        a[endRun += len] = 1;
    }
    a[length - 1] = 0;
    return a;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:TimSortStackSize2.java

示例10: sendIRCode

import java.util.Arrays; //導入方法依賴的package包/類
private boolean sendIRCode(final IrCodeData irCode){
    if(irCode == null || irCode.getIrCodeLen() == 0)
    {
        Log.e(TAG, "RM3 doesn't have IR code. Please teach for it");
        return false;
    }
    int len = irCode.getIrCodeLen() + 4;
    int[] packet = new int[len];
    Arrays.fill(packet, 0x00);
    packet[0] = 0x02;
    packet[1] = 0x00;
    packet[2] = 0x00;
    packet[3] = 0x00;
    Log.d(TAG, "sendIRCode");
    for(int i = 4;i < len;i++) {
        packet[i] = irCode.getIrCodeData()[i - 4];
    }

    PacketData inputData = new PacketData(packet, len);
    PacketData outputData = sendPacket(RM3_CMD_SEND_DATA, inputData);
    if(outputData == null || outputData.getLength() == 0 || outputData.getLength() <= UDP_PACKAGE_SIZE) {
        Log.e(TAG, "sendIRCode: Failed to send IR code");
        Log.d(TAG, "sendIRCode: retry authorize");
        if(true == authorize()) {
            return sendIRCode(irCode);
        }
        return false;
    }
    Log.d(TAG, "sendIRCode: Succeed to send IR code");
    return true;
}
 
開發者ID:dmtan90,項目名稱:Sense-Hub-Android-Things,代碼行數:32,代碼來源:Rm3Connector.java

示例11: MultiStateAlphaController

import java.util.Arrays; //導入方法依賴的package包/類
public MultiStateAlphaController(View view, int stateCount) {
    mTargetView = view;
    mAlphas = new float[stateCount];
    Arrays.fill(mAlphas, 1);

    mAm = (AccessibilityManager) view.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:8,代碼來源:MultiStateAlphaController.java

示例12: RegionRenderCache

import java.util.Arrays; //導入方法依賴的package包/類
public RegionRenderCache(World worldIn, BlockPos posFromIn, BlockPos posToIn, int subIn)
{
    super(worldIn, posFromIn, posToIn, subIn);
    this.position = posFromIn.subtract(new Vec3i(subIn, subIn, subIn));
    boolean flag = true;
    this.combinedLights = allocateLights(8000);
    Arrays.fill((int[])this.combinedLights, (int) - 1);
    this.blockStates = allocateStates(8000);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:10,代碼來源:RegionRenderCache.java

示例13: reallocate

import java.util.Arrays; //導入方法依賴的package包/類
void reallocate(int newCapacity) {
    if (newCapacity > capacity) {
        //extend keys
        long[] new_keys = new long[newCapacity];
        if (keys != null) {
            System.arraycopy(keys, 0, new_keys, 0, capacity);
        }
        keys = new_keys;
        //extend values
        long[] new_values = new long[newCapacity];
        if (values != null) {
            System.arraycopy(values, 0, new_values, 0, capacity);
        }
        values = new_values;

        int[] new_nexts = new int[newCapacity];
        int[] new_hashes = new int[newCapacity * 2];
        Arrays.fill(new_nexts, 0, newCapacity, -1);
        Arrays.fill(new_hashes, 0, (newCapacity * 2), -1);
        hashs = new_hashes;
        nexts = new_nexts;
        for (int i = 0; i < mapSize; i++) {
            int new_key_hash = (int) HashHelper.longHash(key(i), newCapacity * 2);
            setNext(i, hash(new_key_hash));
            setHash(new_key_hash, i);
        }
        capacity = newCapacity;
    }
}
 
開發者ID:datathings,項目名稱:greycat,代碼行數:30,代碼來源:HeapLongLongMap.java

示例14: createBundle

import java.util.Arrays; //導入方法依賴的package包/類
public synchronized void createBundle() {
  Arrays.fill(sndOSCBundleData, (byte) 0);
  oscBundleTotalSize = 0;

  byte[] bundlePrefix = "#bundle".getBytes();

  for (int i = 0; i < bundlePrefix.length; i++) {
    sndOSCBundleData[i] = bundlePrefix[i];
  }

  oscBundleTotalSize += 8; // #bundle
  oscBundleTotalSize += 8; // timetag
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:14,代碼來源:MemeOSC.java

示例15: setUp

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * initializes the Object set of this hash table.
 *
 * @param initialCapacity an <code>int</code> value
 * @return an <code>int</code> value
 */
public int setUp(int initialCapacity) {
    int capacity;

    capacity = super.setUp(initialCapacity);
    _set = new Object[capacity];
    Arrays.fill(_set, FREE);
    return capacity;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:15,代碼來源:TObjectHash.java


注:本文中的java.util.Arrays.fill方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。