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


Java BitSet.length方法代码示例

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


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

示例1: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"GeographicalRegion\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"Regions\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:35,代码来源:GeographicalRegion.java

示例2: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"ConnectivityNodeContainer\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"TopologicalNode\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:35,代码来源:ConnectivityNodeContainer.java

示例3: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"Switch\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:31,代码来源:Switch.java

示例4: marshal

import java.util.BitSet; //导入方法依赖的package包/类
@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    final BitSet bitSet = (BitSet)source;
    final StringBuilder buffer = new StringBuilder();
    boolean seenFirst = false;
    for (int i = 0; i < bitSet.length(); i++) {
        if (bitSet.get(i)) {
            if (seenFirst) {
                buffer.append(',');
            } else {
                seenFirst = true;
            }
            buffer.append(i);
        }
    }
    writer.setValue(buffer.toString());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:BitSetConverter.java

示例5: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"EnergyConsumer\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"LoadResponse\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:35,代码来源:EnergyConsumer.java

示例6: main

import java.util.BitSet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    BitSet a = new BitSet();
    BitSet b = new BitSet();

    a.set(0);
    a.set(70);
    b.set(40);
    a.and(b);
    if (a.length() != 0)
        throw new RuntimeException("Incorrect length after and().");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:And.java

示例7: insertAt

import java.util.BitSet; //导入方法依赖的package包/类
/** Inserts specified amount of bits into the set.
 */
private static BitSet insertAt (BitSet b, int at, int len, int size) {
    BitSet before = b.get (0, at);
    
    BitSet res = new BitSet (size);
    res.or (before);
    
    int max = b.length ();
    while (at < max) {
        res.set (at + len, b.get (at));
        at++;
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:LazyListModel.java

示例8: removeAt

import java.util.BitSet; //导入方法依赖的package包/类
/** Removes specified amount of bits from the set.
 */
private static BitSet removeAt (BitSet b, int at, int len, int newSize) {
    BitSet clone = (BitSet)b.clone ();
    
    int max = b.length ();
    while (at < max) {
        clone.set (at, b.get (at + len));
        at++;
    }
    clone.set (newSize, b.size (), false);
    return clone;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LazyListModel.java

示例9: assertIndex

import java.util.BitSet; //导入方法依赖的package包/类
private void assertIndex(final BitSet expected) throws IOException, InterruptedException {
    for (int i=0; i < expected.length(); i++) {
        final Collection<? extends IndexDocument> res = index.query("bin", Integer.toBinaryString(i), Queries.QueryKind.EXACT, "bin","oct");
        boolean should = expected.get(i);
        assertEquals(should, res.size()==1);
        if (should) {
            assertEquals(res.iterator().next().getValue("bin"), Integer.toBinaryString(i));
            assertEquals(res.iterator().next().getValue("oct"), Integer.toOctalString(i));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LuceneIndexTest.java

示例10: write

import java.util.BitSet; //导入方法依赖的package包/类
public void write(JsonWriter out, BitSet src) throws IOException {
  if (src == null) {
    out.nullValue();
    return;
  }

  out.beginArray();
  for (int i = 0; i < src.length(); i++) {
    int value = (src.get(i)) ? 1 : 0;
    out.value(value);
  }
  out.endArray();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:TypeAdapters.java

示例11: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"ControlAreaGeneratingUnit\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"GeneratingUnit\" needs to be set\n");
    }

    if (isNotSet.get(1)) {
        message.append("\t\"ControlArea\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:39,代码来源:ControlAreaGeneratingUnit.java

示例12: convert

import java.util.BitSet; //导入方法依赖的package包/类
private static long convert(BitSet bits) {
    long value = 0L;
    for (int i = 0; i < bits.length(); ++i) {
        value += bits.get(i) ? (1L << i) : 0L;
    }
    return value;
}
 
开发者ID:tmobile,项目名称:keybiner,代码行数:8,代码来源:Permission64.java

示例13: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"IdentifiedObject\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"description\" needs to be set\n");
    }

    if (isNotSet.get(1)) {
        message.append("\t\"aliasName\" needs to be set\n");
    }

    if (isNotSet.get(2)) {
        message.append("\t\"name\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:43,代码来源:IdentifiedObject.java

示例14: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"SubGeographicalRegion\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"Region\" needs to be set\n");
    }

    if (isNotSet.get(1)) {
        message.append("\t\"Substations\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:39,代码来源:SubGeographicalRegion.java

示例15: getMessageForConsistency

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Utility in charge of creating the message when the class is not
 * consistent within a specific context
 *
 * @param minBitset
 *            bitset describing which CIM attributes of this class have
 *            to be set so that it is consistent within a
 *            specific subset context
 * @return the message explaining what is not consistent
 */
private String getMessageForConsistency(final BitSet minBitset) {

    StringBuilder message = new StringBuilder(
            "Instance of \"SvTapStep\" of id \"");
    message.append(this.getId());
    message.append("\" is not consistent in this context:\n");
    /*
     * XOR and then AND
     * The result is :
     * "1" : has not been set and need to be
     * "0" : has been set or is not mandatory
     */

    BitSet isNotSet = new BitSet(minBitset.length());
    isNotSet.or(minBitset);
    // we create a copy of minBitset
    isNotSet.xor(this.currentBitset);
    isNotSet.and(minBitset);

    if (isNotSet.get(0)) {
        message.append("\t\"continuousPosition\" needs to be set\n");
    }

    if (isNotSet.get(1)) {
        message.append("\t\"TapChanger\" needs to be set\n");
    }
    return message.toString();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:39,代码来源:SvTapStep.java


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