当前位置: 首页>>代码示例>>Java>>正文


Java BitArray.set方法代码示例

本文整理汇总了Java中sun.security.util.BitArray.set方法的典型用法代码示例。如果您正苦于以下问题:Java BitArray.set方法的具体用法?Java BitArray.set怎么用?Java BitArray.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.security.util.BitArray的用法示例。


在下文中一共展示了BitArray.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setZero

import sun.security.util.BitArray; //导入方法依赖的package包/类
@Override
public void setZero(int[][] matrix) {
    final BitArray rows = new BitArray(matrix.length);
    final BitArray cols = new BitArray(matrix[0].length);
    for (int i = 0; i < matrix.length; i++) {
        for (int j = 0; j < matrix[i].length; j++) {
            final int item = matrix[i][j];
            rows.set(i, rows.get(i) || item == 0);
            cols.set(j, cols.get(j) || item == 0);
        }
    }
    for (int i = 0; i < rows.length(); i++) {
        for (int j = 0; j < cols.length(); j++) {
            if (rows.get(i) || cols.get(j)) {
                matrix[i][j] = 0;
            }
        }
    }
}
 
开发者ID:mmnaseri,项目名称:cs-review,代码行数:20,代码来源:ZeroMatrixImpl.java

示例2: parseIPv6

import sun.security.util.BitArray; //导入方法依赖的package包/类
private void parseIPv6(String name) throws IOException {

        int slashNdx = name.indexOf('/');
        if (slashNdx == -1) {
            address = InetAddress.getByName(name).getAddress();
        } else {
            address = new byte[32];
            byte[] base = InetAddress.getByName
                (name.substring(0, slashNdx)).getAddress();
            System.arraycopy(base, 0, address, 0, 16);

            // append a mask corresponding to the num of prefix bits specified
            int prefixLen = Integer.parseInt(name.substring(slashNdx+1));
            if (prefixLen > 128)
                throw new IOException("IPv6Address prefix is longer than 128");

            // create new bit array initialized to zeros
            BitArray bitArray = new BitArray(MASKSIZE * 8);

            // set all most significant bits up to prefix length
            for (int i = 0; i < prefixLen; i++)
                bitArray.set(i, true);
            byte[] maskArray = bitArray.toByteArray();

            // copy mask bytes into mask portion of address
            for (int i = 0; i < MASKSIZE; i++)
                address[MASKSIZE+i] = maskArray[i];
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:IPAddressName.java

示例3: parseIPv6

import sun.security.util.BitArray; //导入方法依赖的package包/类
private void parseIPv6(String name) throws IOException {

        int slashNdx = name.indexOf('/');
        if (slashNdx == -1) {
            address = InetAddress.getByName(name).getAddress();
        } else {
            address = new byte[32];
            byte[] base = InetAddress.getByName
                (name.substring(0, slashNdx)).getAddress();
            System.arraycopy(base, 0, address, 0, 16);

            // append a mask corresponding to the num of prefix bits specified
            int prefixLen = Integer.parseInt(name.substring(slashNdx+1));
            if (prefixLen < 0 || prefixLen > 128) {
                throw new IOException("IPv6Address prefix length (" +
                        prefixLen + ") in out of valid range [0,128]");
            }

            // create new bit array initialized to zeros
            BitArray bitArray = new BitArray(MASKSIZE * 8);

            // set all most significant bits up to prefix length
            for (int i = 0; i < prefixLen; i++)
                bitArray.set(i, true);
            byte[] maskArray = bitArray.toByteArray();

            // copy mask bytes into mask portion of address
            for (int i = 0; i < MASKSIZE; i++)
                address[MASKSIZE+i] = maskArray[i];
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:32,代码来源:IPAddressName.java


注:本文中的sun.security.util.BitArray.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。