本文整理汇总了Java中org.apache.commons.lang3.mutable.MutableInt.increment方法的典型用法代码示例。如果您正苦于以下问题:Java MutableInt.increment方法的具体用法?Java MutableInt.increment怎么用?Java MutableInt.increment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.mutable.MutableInt
的用法示例。
在下文中一共展示了MutableInt.increment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCallTwice
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallTwice() throws Exception {
final MutableInt callCount = new MutableInt(0);
final MutableBoolean called = new MutableBoolean(false);
Polling p = new Polling() {
@Override
public Boolean call() throws Exception {
callCount.increment();
boolean b = called.booleanValue();
called.setTrue();
return b;
}
};
p.poll(500, 10);
assertEquals(2, callCount.intValue());
}
示例2: testCallTimeout
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallTimeout() throws Exception {
final MutableInt callCount = new MutableInt(0);
Polling p = new Polling() {
@Override
public Boolean call() throws Exception {
callCount.increment();
return false;
}
};
try {
p.poll(100, 10);
} catch (TimeoutException e ) {
assertTrue("Expected to execute call() at least 4 times, got instead only " + callCount.intValue() + " calls",
callCount.intValue() > 5);
return;
}
fail("Did not reach timeout");
}
示例3: testCallableTwice
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallableTwice() throws Exception {
final MutableInt callCount = new MutableInt(0);
final MutableBoolean called = new MutableBoolean(false);
Polling p = new Polling(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
callCount.increment();
boolean b = called.booleanValue();
called.setTrue();
return b;
}
});
p.poll(500, 10);
assertEquals(2, callCount.intValue());
}
示例4: testCallableTimeout
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallableTimeout() throws Exception {
final MutableInt callCount = new MutableInt(0);
Polling p = new Polling(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
callCount.increment();
return false;
}
});
try {
p.poll(100, 10);
} catch (TimeoutException e ) {
assertTrue("Expected to execute call() at least 4 times, got instead only " + callCount.intValue() + " calls",
callCount.intValue() > 5);
return;
}
fail("Did not reach timeout");
}
示例5: process
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Override
public void process(T t)
{
if (pattern.checkState(t, 0)) {
partialMatches.add(new MutableInt(-1));
}
if (partialMatches.size() > 0) {
MutableInt tempInt;
Iterator<MutableInt> itr = partialMatches.iterator();
while (itr.hasNext()) {
tempInt = itr.next();
tempInt.increment();
if (!pattern.checkState(t, tempInt.intValue())) {
itr.remove();
} else if (tempInt.equals(patternLength)) {
itr.remove();
processPatternFound();
}
}
}
}
示例6: register
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
/**
* Assign id to given annotation, add it to this container and return it.
*
* @param anno
* @return given anno with assigned id.
*/
public <B extends BratAnnotation<?>> B register(B anno) {
// sanity check 1
if (anno.getId() != null) {
throw new IllegalArgumentException(String.format(
"Can not register anno %s with non-null id", anno.getId()));
}
// sanity check 2
checkTypeRegistration(anno.getType());
// calc id
MutableInt counter = getCounterForTypeOf(anno);
String idPrefix = getPrefixForTypeOf(anno);
counter.increment();
// assign id
anno.setNumId(counter.longValue());
anno.setId(idPrefix + counter);
// memorize
add(anno);
return anno;
}
示例7: isBadWord
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
/**
*
* @param anno the word anno
* @param badChars the bad char counter. Being incremented
* @return true if the word has one bad char, false otherwise
*/
private boolean isBadWord(WordAnnotation anno, MutableInt badChars) {
final String coveredText = anno.getCoveredText();
boolean foundOneBadChar = false;
for(int i=0; i< coveredText.length(); i++) {
boolean found = false;
char c = coveredText.charAt(i);
for(char a:this.allowedChars) {
if(a==c)
found = true;
}
if(!found) {
badChars.increment();
foundOneBadChar = true;
}
}
return foundOneBadChar;
}
示例8: testCallOnce
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallOnce() throws Exception {
final MutableInt callCount = new MutableInt(0);
Polling p = new Polling() {
@Override
public Boolean call() throws Exception {
callCount.increment();
return true;
}
};
p.poll(500, 10);
assertEquals(1, callCount.intValue());
}
示例9: testNegativeTimeout
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testNegativeTimeout() throws Exception {
final MutableInt callCount = new MutableInt(0);
Polling p = new Polling() {
@Override
public Boolean call() throws Exception {
callCount.increment();
return true;
}
};
p.poll(-1, 10);
assertEquals(1, callCount.intValue());
}
示例10: testCallableOnce
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void testCallableOnce() throws Exception {
final MutableInt callCount = new MutableInt(0);
final MutableBoolean called = new MutableBoolean(false);
Polling p = new Polling(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
callCount.increment();
return true;
}
});
p.poll(500, 10);
assertEquals(1, callCount.intValue());
}
示例11: test_chunks_sequenced
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
@Test
public void test_chunks_sequenced() throws IOException {
MutableInt parsed = new MutableInt(0);
AsyncJsonParser parser = new AsyncJsonParser(root -> {
parsed.increment();
try {
Model deserialized = mapper.treeToValue(root, Model.class);
Assert.assertEquals(deserialized, model);
} catch (JsonProcessingException e) {
Assert.fail(e.getMessage());
}
});
byte[] bytes = new ObjectMapper().writeValueAsBytes(model);
byte[] allBytes = new byte[3 * bytes.length];
System.arraycopy(bytes, 0, allBytes, bytes.length * 0, bytes.length);
System.arraycopy(bytes, 0, allBytes, bytes.length * 1, bytes.length);
System.arraycopy(bytes, 0, allBytes, bytes.length * 2, bytes.length);
final int CHUNK_SIZE = 20;
for (int i = 0; i < allBytes.length; i += CHUNK_SIZE) {
byte[] chunk = new byte[20];
int start = Math.min(allBytes.length, i);
int len = Math.min(CHUNK_SIZE, allBytes.length - i);
System.arraycopy(allBytes, start, chunk, 0, len);
System.out.println(new String(chunk));
parser.consume(chunk, len);
}
Assert.assertEquals(3, parsed.intValue());
}
示例12: markAsUsed
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
private void markAsUsed(T object) {
MutableInt usages = usageMap.get(object);
if (usages == null) {
usageMap.put(object, new MutableInt(1));
} else {
usages.increment();
}
}
示例13: mode
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
/**
* Find the most frequently occurring item.
*
* @param <T> type of values processed by this method
* @param items to check
* @return most populous T, {@code null} if non-unique or no items supplied
* @since 3.0.1
*/
public static <T> T mode(final T... items) {
if (ArrayUtils.isNotEmpty(items)) {
final HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(items.length);
for (final T t : items) {
final MutableInt count = occurrences.get(t);
if (count == null) {
occurrences.put(t, new MutableInt(1));
} else {
count.increment();
}
}
T result = null;
int max = 0;
for (final Map.Entry<T, MutableInt> e : occurrences.entrySet()) {
final int cmp = e.getValue().intValue();
if (cmp == max) {
result = null;
} else if (cmp > max) {
max = cmp;
result = e.getKey();
}
}
return result;
}
return null;
}
示例14: create
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
/**
* Creates an {@link AllelicPanelOfNormals} given a site-frequency threshold;
* sites appearing in strictly less than this fraction of samples will not be included in the panel of normals.
* @param siteFrequencyThreshold site-frequency threshold
* @return an {@link AllelicPanelOfNormals} containing sites
* above the site-frequency threshold
*/
public AllelicPanelOfNormals create(final double siteFrequencyThreshold) {
logger.info("Creating allelic panel of normals...");
final Map<SimpleInterval, MutableInt> numberOfSamplesMap = new HashMap<>(); //used to filter on frequency
final Map<SimpleInterval, AllelicCount> totalCountsMap = new HashMap<>(); //store only the total counts (smaller memory footprint)
int pulldownFileCounter = 1;
final int totalNumberOfSamples = pulldownFiles.size();
for (final File pulldownFile : pulldownFiles) {
logger.info("Processing pulldown file " + pulldownFileCounter++ + "/" + totalNumberOfSamples + " (" + pulldownFile + ")...");
final AllelicCountCollection pulldownCounts = new AllelicCountCollection(pulldownFile);
for (final AllelicCount count : pulldownCounts.getCounts()) {
//update the sum of ref and alt counts at each site
final SimpleInterval site = count.getInterval();
final AllelicCount currentCountAtSite = totalCountsMap.getOrDefault(site, new AllelicCount(site, 0, 0));
final AllelicCount updatedCountAtSite = new AllelicCount(
site,
currentCountAtSite.getRefReadCount() + count.getRefReadCount(),
currentCountAtSite.getAltReadCount() + count.getAltReadCount());
totalCountsMap.put(site, updatedCountAtSite);
//update the number of samples seen possessing each site
final MutableInt numberOfSamplesAtSite = numberOfSamplesMap.get(site);
if (numberOfSamplesAtSite == null) {
numberOfSamplesMap.put(site, new MutableInt(1));
} else {
numberOfSamplesAtSite.increment();
}
}
}
logger.info("Total number of unique sites present in samples: " + totalCountsMap.size());
//filter out sites that appear at a frequency strictly less than the provided threshold
final AllelicCountCollection totalCounts = new AllelicCountCollection();
numberOfSamplesMap.entrySet().stream()
.filter(e -> e.getValue().doubleValue() / totalNumberOfSamples >= siteFrequencyThreshold)
.map(e -> totalCountsMap.get(e.getKey()))
.forEach(totalCounts::add);
logger.info(String.format("Number of unique sites present in samples above site frequency = %4.3f: %d", siteFrequencyThreshold, totalCounts.getCounts().size()));
return new AllelicPanelOfNormals(totalCounts);
}
示例15: remapForCountsPerPeptideLength
import org.apache.commons.lang3.mutable.MutableInt; //导入方法依赖的package包/类
/**
* @param allSearchesCombinedPeptideLengthList_Map_KeyedOnSearchId_KeyedOnLinkType
* @return
*/
private Map<String,Map<Integer,Map<Integer,MutableInt>>> remapForCountsPerPeptideLength(
/**
* Lists of peptideLength mapped by search id then link type
* Map<[link type], Map<[Search Id],List<[Peptide Length]>>>
*/
Map<String,Map<Integer,List<Integer>>> allSearchesCombinedPeptideLengthList_Map_KeyedOnSearchId_KeyedOnLinkType
) {
Map<String,Map<Integer,Map<Integer,MutableInt>>> countsKeyPeptideLength_KeySearchId_KeyLinkType = new HashMap<>();
for ( Map.Entry<String,Map<Integer,List<Integer>>> entryByLinkType : allSearchesCombinedPeptideLengthList_Map_KeyedOnSearchId_KeyedOnLinkType.entrySet() ) {
Map<Integer,Map<Integer,MutableInt>> countsKeyPeptideLength_KeySearchId = new HashMap<>();
countsKeyPeptideLength_KeySearchId_KeyLinkType.put( entryByLinkType.getKey() , countsKeyPeptideLength_KeySearchId );
for ( Map.Entry<Integer,List<Integer>> entryBySearchId : entryByLinkType.getValue().entrySet() ) {
Map<Integer,MutableInt> countsKeyPeptideLength = new HashMap<>();
countsKeyPeptideLength_KeySearchId.put( entryBySearchId.getKey(), countsKeyPeptideLength );
for ( Integer peptideLength : entryBySearchId.getValue() ) {
MutableInt countForPeptideLength = countsKeyPeptideLength.get( peptideLength );
if ( countForPeptideLength == null ) {
countsKeyPeptideLength.put( peptideLength, new MutableInt( 1 ) );
} else {
countForPeptideLength.increment();
}
}
}
}
return countsKeyPeptideLength_KeySearchId_KeyLinkType;
}
开发者ID:yeastrc,项目名称:proxl-web-app,代码行数:33,代码来源:PeptideLength_Histogram_For_PSMPeptideCutoffs_Merged.java