List of usage examples for java.util BitSet set
public void set(int bitIndex)
From source file:org.apache.openjpa.kernel.DetachManager.java
/** * Create a bit set for the fields in the current fetch groups. *//* w ww . jav a 2 s .c o m*/ private static void setFetchGroupFields(Broker broker, StateManagerImpl sm, BitSet idxs) { FetchConfiguration fetch = broker.getFetchConfiguration(); FieldMetaData[] fmds = sm.getMetaData().getFields(); for (int i = 0; i < fmds.length; i++) { if (fmds[i].isPrimaryKey() || fetch.requiresFetch(fmds[i]) != FetchConfiguration.FETCH_NONE) idxs.set(i); } }
From source file:org.apache.kylin.cube.cuboid.algorithm.ITGeneticAlgorithmTest.java
@Test public void testChromosomeIsSame() { BenefitPolicy benefitPolicy = new BPUSCalculator(cuboidStats); double maxSpaceLimit = cuboidStats.getBaseCuboidSize() * 10; BitsChromosomeHelper helper = new BitsChromosomeHelper(maxSpaceLimit, cuboidStats); double maxSpaceLimit1 = cuboidStats.getBaseCuboidSize() * 12; BitsChromosomeHelper helper1 = new BitsChromosomeHelper(maxSpaceLimit1, cuboidStats); BitSet representation = new BitSet(); representation.set(10); Chromosome chromosome = new BitsChromosome(representation, benefitPolicy, helper); Set<Chromosome> chromosomeSet = Sets.newHashSet(chromosome); BitSet representation1 = new BitSet(); representation1.set(10);/*from w w w . ja v a 2 s . c o m*/ chromosomeSet.add(((BitsChromosome) chromosome).newBitsChromosome(representation1)); assertEquals(1, chromosomeSet.size()); BitSet representation2 = new BitSet(); representation2.set(12); chromosomeSet.add(((BitsChromosome) chromosome).newBitsChromosome(representation2)); assertEquals(2, chromosomeSet.size()); BitSet representation3 = new BitSet(); representation3.set(12); chromosomeSet.add(new BitsChromosome(representation3, benefitPolicy, helper1)); assertEquals(2, chromosomeSet.size()); }
From source file:org.rifidi.edge.adapter.alien.AlienGPIOService.java
@Override public void setGPO(String readerID, Collection<Integer> ports) throws CannotExecuteException { Alien9800ReaderSession session = getSession(readerID); BitSet bits = new BitSet(8); for (Integer port : ports) { bits.set(port); }//w w w.j a v a 2s .co m logger.info("Setting GPO on " + readerID + " Ports: " + ports); session.setOutputPort(bits); }
From source file:org.rifidi.edge.adapter.alien.AlienGPIOService.java
@Override public void flashGPO(String readerID, int flashTime, Set<Integer> ports) throws CannotExecuteException { Alien9800ReaderSession session = getSession(readerID); BitSet bits = new BitSet(8); for (Integer port : ports) { bits.set(port); }/*from ww w.j a va 2 s . co m*/ logger.info("Flashing GPO on " + readerID + " Ports: " + ports + " for " + flashTime + " seconds"); session.flashOutput(bits, new BitSet(), flashTime, 0, 1); }
From source file:TypeConversionHelper.java
/** * Convert a boolean[] into an instance of our value class. * * @param buf boolean array to be converted * * @return converted boolean array as BitSet *///from ww w.j a v a 2s.c o m public static BitSet getBitSetFromBooleanArray(boolean[] buf) { BitSet set = new BitSet(); for (int i = 0; i < buf.length; i++) { if (buf[i]) { set.set(i); } } return set; }
From source file:com.opengamma.analytics.math.minimization.NonLinearTransformFunctionTest.java
@Test public void testNullTransform() { BitSet fixed = new BitSet(); fixed.set(0); DoubleMatrix1D start = new DoubleMatrix1D(new double[] { Math.PI / 4, 1 }); UncoupledParameterTransforms transforms = new UncoupledParameterTransforms(start, NULL_TRANSFORMS, fixed); NonLinearTransformFunction transFunc = new NonLinearTransformFunction(FUNCTION, JACOBIAN, transforms); Function1D<DoubleMatrix1D, DoubleMatrix1D> func = transFunc.getFittingFunction(); Function1D<DoubleMatrix1D, DoubleMatrix2D> jacFunc = transFunc.getFittingJacobian(); DoubleMatrix1D x = new DoubleMatrix1D(new double[] { 0.5 }); final double rootHalf = Math.sqrt(0.5); DoubleMatrix1D y = func.evaluate(x); assertEquals(3, y.getNumberOfElements()); assertEquals(rootHalf * Math.cos(0.5), y.getEntry(0), 1e-9); assertEquals(rootHalf * Math.sin(0.5), y.getEntry(1), 1e-9); assertEquals(rootHalf, y.getEntry(2), 1e-9); DoubleMatrix2D jac = jacFunc.evaluate(x); assertEquals(3, jac.getNumberOfRows()); assertEquals(1, jac.getNumberOfColumns()); assertEquals(-rootHalf * Math.sin(0.5), jac.getEntry(0, 0), 1e-9); assertEquals(rootHalf * Math.cos(0.5), jac.getEntry(1, 0), 1e-9); assertEquals(0, jac.getEntry(2, 0), 1e-9); }
From source file:org.onosproject.teyang.utils.topology.NodeConverter.java
private static TeNode yang2TeSubsystemNodeAugment(Te yangNodeAugTe, TeNodeId teNodeId, Network yangNetwork, Networks yangNetworks, Node yangNode, Map<KeyId, TerminationPoint> teTps) { NodeId yangNodeId = yangNode.nodeId(); NetworkId yangNetworkId = yangNetwork.networkId(); long teNodeIdLong = Ip4Address.valueOf(teNodeId.dottedQuad().string()).toInt(); TeTopologyKey underlayTopologyIdId = null; // FIXME: yang has a list of supporting nodes, but TeNode only has one // supportTeNodeId. How ro retrieve providerId, clientId, topologyId, teNodeId? TeNodeKey supportTeNodeId = null;/*from w w w . j a v a 2 s . c o m*/ // supportTeNodeId = new TeNodeKey(providerId, clientId, topologyId, teNodeId) // yangSupportNodes.get(0). TeNodeKey sourceTeNodeId = null; //ignore CommonNodeData teData = null; Map<Long, ConnectivityMatrix> connMatrices = null; Map<Long, org.onosproject.tetopology.management.api.node.TunnelTerminationPoint> ttps = null; List<Long> teLinkIds = Lists.newArrayList(); List<Long> teTpIds = Lists.newArrayList(); // ********************************************** to find teLinkIds // teLinkIds should be supposed to get from YANG Link and TP data. // For now, assuming each teTp is sourcing a TE link . if (MapUtils.isNotEmpty(teTps)) { for (Map.Entry<KeyId, TerminationPoint> entry : teTps.entrySet()) { if (entry.getValue().teTpId() != null) { teTpIds.add(entry.getValue().teTpId()); teLinkIds.add(entry.getValue().teTpId()); } } } // ********************************************** to find teTpIds // if (yangNode.yangAugmentedInfoMap() != null // && !yangNode.yangAugmentedInfoMap().isEmpty()) { // // AugmentedNdNode yangTpNodeAugment = (AugmentedNdNode) yangNode // .yangAugmentedInfo(AugmentedNdNode.class); // // if (yangTpNodeAugment.terminationPoint() != null) { // for (org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology // .rev20151208.ietfnetworktopology.networks.network.node.augmentedndnode.TerminationPoint // yangTpnode : yangTpNodeAugment.terminationPoint()) { // teTpIds.add(Long.valueOf(yangTpnode.tpId().uri().string())); // } // } // } // ********************************************** Config ynodeAugCfg = yangNodeAugTe.config(); if (ynodeAugCfg != null) { TeNodeAttributes teNodeAttr = ynodeAugCfg.teNodeAttributes(); if (teNodeAttr != null) { if (teNodeAttr.underlayTopology() != null) { underlayTopologyIdId = yang2TeSubsystemNodeUnderlayTopology(teNodeAttr.underlayTopology(), yangNetworks); } BitSet flags = new BitSet(); if (teNodeAttr.isAbstract()) { flags.set(TeNode.BIT_ABSTRACT); } teData = new CommonNodeData(null, // teNodeAttr.name().string(), EnumConverter.yang2TeSubsystemAdminStatus(teNodeAttr.adminStatus()), EnumConverter.yang2TeSubsystemOpStatus(yangNodeAugTe.state().operStatus()), flags); // if (teNodeAttr.connectivityMatrix() != null) { if (teNodeAttr.connectivityMatrices() != null) { connMatrices = yang2TeSubsystemNodeConnectivityMatrix(yangNetworkId.uri().toString(), yangNodeId.uri().toString(), teNodeAttr.connectivityMatrices()); } } } if (yangNodeAugTe.tunnelTerminationPoint() != null) { ttps = yang2TeSubsystemTtp(yangNodeAugTe.tunnelTerminationPoint(), yangNode, yangNetworks); } TeNode teNode = new DefaultTeNode(teNodeIdLong, underlayTopologyIdId, supportTeNodeId, sourceTeNodeId, teData, connMatrices, teLinkIds, ttps, teTpIds); return teNode; }
From source file:inflor.core.singlets.SingletsModel.java
public BitSet scoreModel(double[] ratio) { final BitSet mask = new BitSet(ratio.length); for (int i = 0; i < mask.size(); i++) { if (ratio[i] <= ratioThreshold) { mask.set(i); }//ww w . j av a 2s . c o m } return mask; }
From source file:org.openhab.binding.satel.internal.protocol.command.ControlObjectCommand.java
/** * {@inheritDoc}//from ww w .j av a2 s . c o m */ @Override public void handleResponse(SatelMessage response) { if (commandSucceeded(response)) { // force outputs refresh BitSet newStates = new BitSet(); // TODO generalize for all kinds of control if (this.controlType instanceof OutputControl) { newStates.set(OutputState.OUTPUT.getRefreshCommand()); this.getEventDispatcher().dispatchEvent(new NewStatesEvent(newStates)); } } }
From source file:net.bioclipse.cdk.ui.sdfeditor.CDKFingerPrintPropertyCalculator.java
public BitSet parse(String value) { // TODO check if this is right byte[] bytes = new Base64().decode(value.getBytes()); BitSet set = new BitSet(); for (int i = 0; i < bytes.length * 8; i++) { if ((bytes[bytes.length - i / 8 - 1] & (1 << (i % 8))) > 0) { set.set(i); }/* w w w. j ava 2 s. co m*/ } return set; }