Package java.util

Examples of java.util.BitSet$MaskInfo


     */
    private int updateTablesForFeature(Prototypes protos, Feature f) {
        Arrays.fill(this.mrsFeatureEvidence, (short) 0);
        int ActualProtoNum = 0;
        for (Prototype proto : protos) {
            BitSet bsProtoPruner[][] = proto.getProtoPruner();
            /* Prune Protos of current Proto Set */
            BitSet bsProto = (BitSet) bsProtoPruner[0][(f.getX()+128) >> 2].clone();
            bsProto.and(bsProtoPruner[1][(f.getY()+128) >> 2]);
            bsProto.and(bsProtoPruner[2][f.getTheta() >> 2]);
           
            if (!bsProto.isEmpty()) {
                for (int nProto=0;
                    -1 != (nProto = bsProto.nextSetBit(nProto));
                    nProto++) {
                    LearntFeature lf = proto.get(nProto);
                    byte rbConfigs[] = lf.getConfigs();
                    int nX = Math.abs(lf.getA() * f.getX() - lf.getB() * f.getY() + lf.getC());
                    int nY = Math.abs((f.getTheta() - lf.getAngle()) << 8);
View Full Code Here


     * Sets the config bits.
     *
     * @param nInts the new config bits
     */
    private void setConfigBits(int[] nInts) {
      BitSet Configs = new BitSet(Prototypes.MAX_NUM_CONFIGS);
        int k = 0;
        for (int n: nInts) {
            int nBit = 1;
            for (int j=0; j<32; j++, nBit <<= 1) {
                if ((nBit & n) != 0) {
                    Configs.set(k);
                }
                k++;
            }
        }
        this.mrbConfig = new byte[Configs.cardinality()];
        int nBit = 0;
        for (int nConfig = 0;
        -1 != (nConfig = Configs.nextSetBit(nConfig));
        nConfig++) {
          this.mrbConfig[nBit++] = (byte) nConfig;
        }
    }
View Full Code Here

        this(field, new String[] { value });
    }

    public BitSet bits(IndexReader reader) throws IOException {
        //Create a new BitSet with a capacity equal to the size of the index.
        BitSet bits = new BitSet(reader.maxDoc());
        //Match all search terms.
        for (int i=0; i < searchTerms.length; i++) {
            //Get an enumeration of all the documents that match the specified
            //field value.
            TermDocs matchingDocs = reader.termDocs(searchTerms[i]);
            try {
                if (matchingDocs != null) {
                    while(matchingDocs.next()) {
                        bits.set(matchingDocs.doc());
                    }
                }
            }
            finally {
                if (matchingDocs != null) {
View Full Code Here

        if (start < 0 || end < 0) {
            return null;
        }

        BitSet bitSet = new BitSet();
        bitSetAsStr = bitSetAsStr.substring(start + 1, end);
        for (String str : bitSetAsStr.split(",")) {
            str = str.trim();
            if (str.length() > 0)
                bitSet.set(Integer.parseInt(str.trim()));
        }
        return bitSet;
    }
View Full Code Here

        for (Object obj : constrElement.elements()) {
            Element element = (Element) obj;
            Constraint constraint = null;

            if (RasterConstraint.class.getSimpleName().equals(element.getName())) {
                BitSet bs = getResult(obj, BitSet.class, element);
                int length = Integer.parseInt(element.attributeValue("length"));
                constraint = new RasterConstraint(new WeekRasterImpl(
                        new BitRasterImpl(bs, length)));

            } else if (EventOrderConstraint.class.getSimpleName().equals(element.getName())) {
View Full Code Here

    private BitSet bitSet;
    private int iSize;

    public BitRasterImpl(int length) {
        bitSet = new BitSet(length);
        iSize = length;
    }
View Full Code Here

        testGetSet();
        testRandomSetRange();
    }

    private void testNextClearBit() {
        BitSet set = new BitSet();
        BitField field = new BitField();
        set.set(0, 640);
        field.set(0, 640, true);
        assertEquals(set.nextClearBit(0), field.nextClearBit(0));

        Random random = new Random(1);
        field = new BitField();
        field.set(0, 500, true);
        for (int i = 0; i < 100000; i++) {
View Full Code Here

        }
    }

    private void testRandom() {
        BitField bits = new BitField();
        BitSet set = new BitSet();
        int max = 300;
        int count = 100000;
        Random random = new Random(1);
        for (int i = 0; i < count; i++) {
            int idx = random.nextInt(max);
            if (random.nextBoolean()) {
                if (random.nextBoolean()) {
                    bits.set(idx);
                    set.set(idx);
                } else {
                    bits.clear(idx);
                    set.clear(idx);
                }
            } else {
                assertEquals(set.get(idx), bits.get(idx));
                assertEquals(set.nextClearBit(idx), bits.nextClearBit(idx));
                assertEquals(set.length(), bits.length());
            }
        }
    }
View Full Code Here

        }
    }

    private void testRandomSetRange() {
        BitField bits = new BitField();
        BitSet set = new BitSet();
        Random random = new Random(1);
        int maxOffset = 500;
        int maxLen = 500;
        int total = maxOffset + maxLen;
        int count = 10000;
        for (int i = 0; i < count; i++) {
            int offset = random.nextInt(maxOffset);
            int len = random.nextInt(maxLen);
            boolean val = random.nextBoolean();
            set.set(offset, offset + len, val);
            bits.set(offset, offset + len, val);
            for (int j = 0; j < total; j++) {
                assertEquals(set.get(j), bits.get(j));
            }
        }
    }
View Full Code Here

                inputFile.readIntegerArray(nodeinfo[i], 0, 2);
            }

            if (Debug.debugging("vpfserver")) {
                int baseOffset = 24 + nodesInTree * 8;
                BitSet b = new BitSet(nodesInTree);
                int actprimcnt = 0;
                b.set(0);
                for (int i = 0; i < nodesInTree; i++) {
                    if ((baseOffset + nodeinfo[i][0]) != inputFile.getFilePointer()) {
                        throw new FormatException("SI Input appears to be out-of-sync");
                    }
                    StringBuffer pr = new StringBuffer("i=" + (i + 1));
                    pr.append(" offset=" + nodeinfo[i][0]);
                    pr.append(" count=" + nodeinfo[i][1]);
                    for (int j = 0; j < nodeinfo[i][1]; j++) {
                        actprimcnt++;
                        PrimitiveRecord prim = new PrimitiveRecord(inputFile);
                        pr.append("\n\t").append(prim.toString());
                    }
                    if (nodeinfo[i][1] != 0) {
                        if ((i < 15) || ((i + 1) == nodesInTree)) {
                            System.out.println(pr);
                        }
                        b.set(i + 1);
                        if (!b.get((i + 1) / 2)) {
                            throw new FormatException("condition failed");
                        }
                    }
                }
                if (actprimcnt == numberOfPrimitives) {
View Full Code Here

TOP

Related Classes of java.util.BitSet$MaskInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.