当前位置: 首页>>代码示例>>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;未经允许,请勿转载。