List of usage examples for java.util BitSet andNot
public void andNot(BitSet set)
From source file:BitOHoney.java
public static void main(String args[]) { String names[] = { "Java", "Source", "and", "Support" }; BitSet bits = new BitSet(); for (int i = 0, n = names.length; i < n; i++) { if ((names[i].length() % 2) == 0) { bits.set(i);//from w ww .j av a 2 s.c o m } } System.out.println(bits); System.out.println("Size : " + bits.size()); System.out.println("Length: " + bits.length()); for (int i = 0, n = names.length; i < n; i++) { if (!bits.get(i)) { System.out.println(names[i] + " is odd"); } } BitSet bites = new BitSet(); bites.set(0); bites.set(1); bites.set(2); bites.set(3); bites.andNot(bits); System.out.println(bites); }
From source file:BitOHoney1.java
public static void main(String args[]) { String names[] = { "Hershey's Kisses", "Nestle's Crunch", "Snickers", "3 Musketeers", "Milky Way", "Twix", "Mr. Goodbar", "Crunchie", "Godiva", "Charleston Chew", "Cadbury's", "Lindt", "Aero", "Hebert", "Toberlone", "Smarties", "LifeSavers", "Riesen", "Goobers", "Raisenettes", "Nerds", "Tootsie Roll", "Sweet Tarts", "Cotton Candy" }; BitSet bits = new BitSet(); for (int i = 0, n = names.length; i < n; i++) { if ((names[i].length() % 2) == 0) { bits.set(i);/*from w ww.j a v a 2s .c o m*/ } } System.out.println(bits); System.out.println("Size : " + bits.size()); System.out.println("Length: " + bits.length()); for (int i = 0, n = names.length; i < n; i++) { if (!bits.get(i)) { System.out.println(names[i] + " is odd"); } } BitSet bites = new BitSet(); bites.set(0); bites.set(1); bites.set(2); bites.set(3); bites.andNot(bits); System.out.println(bites); }
From source file:Main.java
public static void main(String args[]) { BitSet bites = new BitSet(); bites.set(0);/*from w w w . ja v a2 s . co m*/ bites.set(1); bites.set(2); bites.set(3); System.out.println(bites); bites.andNot(bites); System.out.println(bites); }
From source file:BitOps.java
public static void main(String args[]) { BitSet set = new BitSet(); set.set(1);/*w w w . j av a 2 s . c o m*/ set.set(2); set.set(3); set.set(4); set.set(5); System.out.println(set); BitSet set2 = new BitSet(); set2.set(1); set2.set(3); set2.set(5); set2.set(7); BitSet set3 = (BitSet) set.clone(); set3.and(set2); System.out.println(set3); set3 = (BitSet) set.clone(); set3.or(set2); System.out.println(set3); set3 = (BitSet) set.clone(); set3.xor(set2); System.out.println(set3); set3 = (BitSet) set.clone(); set3.andNot(set2); System.out.println(set3); set3.andNot(null); }
From source file:MainClass.java
public static void main(String args[]) { BitSet bites = new BitSet(); bites.set(0);/*www .j a v a2 s. com*/ bites.set(1); bites.set(2); bites.set(3); System.out.println(bites); bites.and(bites); System.out.println(bites); bites.or(bites); System.out.println(bites); bites.xor(bites); System.out.println(bites); bites.andNot(bites); System.out.println(bites); }
From source file:Main.java
public static void main(String[] args) { BitSet bitset1 = new BitSet(8); BitSet bitset2 = new BitSet(8); // assign values to bitset1 bitset1.set(0);/* w w w .j a va 2 s . c om*/ bitset1.set(1); bitset1.set(2); // assign values to bitset2 bitset2.set(2); bitset2.set(4); bitset2.set(6); // print the sets System.out.println("Bitset1:" + bitset1); System.out.println("Bitset2:" + bitset2); // perform andNot operation for the two bitsets bitset1.andNot(bitset2); // print the new bitset1 System.out.println(bitset1); }
From source file:ca.phon.ipa.features.FeatureSet.java
/** * Produces a new FeatureSet based on the set-subtraction * of the given feature sets./*from w w w .java 2s . c o m*/ * * @param fs1 * @param fs2 * * @return fs1 MINUS fs2 * * */ public static FeatureSet minus(FeatureSet fs1, FeatureSet fs2) { BitSet bs = (BitSet) fs1.features.clone(); bs.andNot(fs2.features); return new FeatureSet(bs); }
From source file:com.textocat.textokit.postagger.DictionaryComplianceChecker.java
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (Word word : JCasUtil.select(jCas, Word.class)) { com.textocat.textokit.morph.fs.Wordform docWf = MorphCasUtils.getOnlyWordform(word); if (docWf == null) { continue; }/*from w ww. j av a 2s . com*/ String wordTxt = normalizeToDictionaryForm(word.getCoveredText()); List<Wordform> dictWfs = dict.getEntries(wordTxt); if (dictWfs == null || dictWfs.isEmpty()) { notDictNum++; continue; } // convert to BitSet BitSet docBits = toGramBits(gramModel, FSUtils.toSet(docWf.getGrammems())); posTrimmer.trimInPlace(docBits); List<BitSet> _dictBitSets = Lists.transform(dictWfs, allGramBitsFunction(dict)); Set<BitSet> dictBitSets = posTrimmer.trimAndMerge(_dictBitSets); dictBitSets = selectClosest(docBits, dictBitSets); if (calcDistance(docBits, dictBitSets.iterator().next()) == 0) { matchedNum++; } else { notMatchedNum++; StringBuilder record = new StringBuilder(wordTxt); record.append('\t'); List<String> gramDiffs = Lists.newLinkedList(); for (BitSet dictBits : dictBitSets) { List<String> grams = Lists.newLinkedList(); { BitSet positiveBits = (BitSet) docBits.clone(); positiveBits.andNot(dictBits); grams.addAll(Lists.transform(gramModel.toGramSet(positiveBits), positiveGramFunc)); } { BitSet negativeBits = (BitSet) dictBits.clone(); negativeBits.andNot(docBits); grams.addAll(Lists.transform(gramModel.toGramSet(negativeBits), negativeGramFunc)); } gramDiffs.add(gramJoiner.join(grams)); } gramSetJoiner.appendTo(record, gramDiffs); // write corpus grams record.append('\t'); gramJoiner.appendTo(record, gramModel.toGramSet(docBits)); // write dict grams record.append('\t'); gramSetJoiner.appendTo(record, Collections2.transform(dictBitSets, gramBitsToString)); out.println(record); } } }
From source file:com.textocat.textokit.morph.ruscorpora.DictionaryAligningTagMapper2.java
@Override public void mapFromRusCorpora(RusCorporaWordform srcWf, com.textocat.textokit.morph.fs.Wordform targetWf) { Word wordAnno = targetWf.getWord();/*from w w w. j av a2 s . c om*/ delegate.mapFromRusCorpora(srcWf, targetWf); // first - check whether tag is in tagset final BitSet wfTag = toGramBits(gm, FSUtils.toList(targetWf.getGrammems())); // skip INIT as a whole new category if (wfTag.get(gm.getGrammemNumId(RNCMorphConstants.RNC_INIT))) { return; } if (wfTag.intersects(rncDistortionsMask)) { wfTag.andNot(rncDistortionsMask); if (!dict.containsGramSet(wfTag)) { onDistortedWordWithUnknownTag(wordAnno, wfTag); } return; } // // if there is no such tag in dictionary then look the word in it String wordStr = wordAnno.getCoveredText(); List<Wordform> dictWfs = dict.getEntries(normalizeToDictionaryForm(wordStr)); if (dictWfs == null || dictWfs.isEmpty()) { // wfTag.isEmpty => NON-LEX if (!wfTag.isEmpty() && !dict.containsGramSet(wfTag)) { onUnknownWordWithUnknownTag(wordAnno, wfTag); } return; } // retain only the gram categories that are represented in RNC tagset Set<BitSet> dictTags = rncTrimmer.trimAndMerge(Lists.transform(dictWfs, allGramBitsFunction(dict))); // search for a unique dictionary entry that has a tag extending the given one List<BitSet> wfExtensions = Lists.newLinkedList(); for (BitSet dTag : dictTags) { if (contains(dTag, wfTag)) { wfExtensions.add(dTag); } } if (wfExtensions.isEmpty()) { onConflictingTag(wordAnno, wfTag); } else if (wfExtensions.size() > 1) { onAmbiguousWordform(wordAnno, wfTag); } else { BitSet newTag = wfExtensions.get(0); if (newTag.cardinality() > wfTag.cardinality()) { List<String> newTagStr = gm.toGramSet(newTag); targetWf.setGrammems(FSUtils.toStringArray(getCAS(targetWf), newTagStr)); onTagExtended(wordAnno, wfTag, newTag); } } }
From source file:com.turn.ttorrent.client.TorrentHandler.java
public void andNotCompletedPieces(BitSet b) { synchronized (lock) { b.andNot(completedPieces); } }