本文整理汇总了Java中java.util.Set.clear方法的典型用法代码示例。如果您正苦于以下问题:Java Set.clear方法的具体用法?Java Set.clear怎么用?Java Set.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Set
的用法示例。
在下文中一共展示了Set.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ConfusionMatrix
import java.util.Set; //导入方法依赖的package包/类
public ConfusionMatrix(int[] truth, int[] prediction) {
if(truth.length != prediction.length){
throw new IllegalArgumentException(String.format("The vector sizes don't match: %d != %d.", truth.length, prediction.length));
}
Set<Integer> ySet = new HashSet<>();
for(int i = 0; i < truth.length; i++){
ySet.add(truth[i]);
}
matrix = new int[ySet.size()][ySet.size()];
for(int i = 0; i < truth.length; i++){
matrix[truth[i]][prediction[i]] += 1;
}
ySet.clear();
}
示例2: updateDeletedBlockId
import java.util.Set; //导入方法依赖的package包/类
private synchronized void updateDeletedBlockId(ExtendedBlock block) {
Set<Long> blockIds = deletedBlockIds.get(block.getBlockPoolId());
if (blockIds == null) {
blockIds = new HashSet<Long>();
deletedBlockIds.put(block.getBlockPoolId(), blockIds);
}
blockIds.add(block.getBlockId());
numDeletedBlocks++;
if (numDeletedBlocks == MAX_DELETED_BLOCKS) {
for (Entry<String, Set<Long>> e : deletedBlockIds.entrySet()) {
String bpid = e.getKey();
Set<Long> bs = e.getValue();
fsdatasetImpl.removeDeletedBlocks(bpid, bs);
bs.clear();
}
numDeletedBlocks = 0;
}
}
示例3: zrangeByLex
import java.util.Set; //导入方法依赖的package包/类
@Test
public void zrangeByLex() {
jedis.zadd("foo", 1, "aa");
jedis.zadd("foo", 1, "c");
jedis.zadd("foo", 1, "bb");
jedis.zadd("foo", 1, "d");
Set<String> expected = new LinkedHashSet<String>();
expected.add("bb");
expected.add("c");
// exclusive aa ~ inclusive c
assertEquals(expected, jedis.zrangeByLex("foo", "(aa", "[c"));
expected.clear();
expected.add("bb");
expected.add("c");
// with LIMIT
assertEquals(expected, jedis.zrangeByLex("foo", "-", "+", 1, 2));
}
示例4: main
import java.util.Set; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
Set<String> stopWords = new HashSet<>(101);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s;
int stopWordsCount;
stopWordsCount = Integer.parseInt(br.readLine());
while (stopWordsCount > 0) {
stopWords.clear();
for (int i = 0; i < stopWordsCount; ++i) {
stopWords.add(br.readLine());
}
while (!(s = br.readLine()).equals(LAST_CASE)) {
String[] words = s.split(" ");
String acronym = words[0];
int result = calculateAcronymVariantsDP(words, stopWords);
if (result > 0) {
System.out.println(acronym + " can be formed in " + result + " ways");
} else {
System.out.println(acronym + " is not a valid abbreviation");
}
}
stopWordsCount = Integer.parseInt(br.readLine());
}
}
示例5: testPolicy
import java.util.Set; //导入方法依赖的package包/类
private void testPolicy() throws IOException {
System.out.println("X.509 Certificate Match on certificatePolicies");
// test encoding of CertificatePoliciesExtension because we wrote the
// code
// bad match
X509CertSelector selector = new X509CertSelector();
Set<String> s = new HashSet<>();
s.add(new String("1.2.5.7.68"));
selector.setPolicy(s);
checkMatch(selector, cert, false);
// good match
DerInputStream in = new DerInputStream(cert.getExtensionValue("2.5.29.32"));
CertificatePoliciesExtension ext = new CertificatePoliciesExtension(false, in.getOctetString());
List<PolicyInformation> policies = ext.get(CertificatePoliciesExtension.POLICIES);
// match on the first policy id
PolicyInformation policyInfo = (PolicyInformation) policies.get(0);
s.clear();
s.add(policyInfo.getPolicyIdentifier().getIdentifier().toString());
selector.setPolicy(s);
checkMatch(selector, cert, true);
}
示例6: processClassC
import java.util.Set; //导入方法依赖的package包/类
private void processClassC(ClassInstance cls) {
Queue<ClassInstance> toCheck = new ArrayDeque<>();
Set<ClassInstance> checked = Util.newIdentityHashSet();
for (MethodInstance method : cls.methods) {
processMethod(method, toCheck, checked);
toCheck.clear();
checked.clear();
}
for (FieldInstance field : cls.fields) {
processField(field, toCheck, checked);
toCheck.clear();
checked.clear();
}
}
示例7: init
import java.util.Set; //导入方法依赖的package包/类
static void init() {
List<String> accountIdStrings = Nxt.getStringListProperty("nxt.debugTraceAccounts");
String logName = Nxt.getStringProperty("nxt.debugTraceLog");
if (accountIdStrings.isEmpty() || logName == null) {
return;
}
Set<Long> accountIds = new HashSet<>();
for (String accountId : accountIdStrings) {
if ("*".equals(accountId)) {
accountIds.clear();
break;
}
accountIds.add(Convert.parseUnsignedLong(accountId));
}
final DebugTrace debugTrace = addDebugTrace(accountIds, logName);
Nxt.getBlockchainProcessor().addListener(new Listener<Block>() {
@Override
public void notify(Block block) {
debugTrace.resetLog();
}
}, BlockchainProcessor.Event.RESCAN_BEGIN);
Logger.logDebugMessage("Debug tracing of " + (accountIdStrings.contains("*") ? "ALL"
: String.valueOf(accountIds.size())) + " accounts enabled");
}
示例8: testBucketFilter
import java.util.Set; //导入方法依赖的package包/类
@Test
public void testBucketFilter() {
createScenarioForBucketFilter();
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_BUCKET_FILTER);
registerFunctionAtServer(function);
Set<Integer> bucketFilterSet = new HashSet<Integer>();
bucketFilterSet.add(3);
bucketFilterSet.add(6);
bucketFilterSet.add(8);
client.invoke(() -> PRClientServerTestBase.serverBucketFilterExecution(bucketFilterSet));
bucketFilterSet.clear();
// Test single filter
bucketFilterSet.add(7);
client.invoke(() -> PRClientServerTestBase.serverBucketFilterExecution(bucketFilterSet));
}
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.java
示例9: testPlusMatch
import java.util.Set; //导入方法依赖的package包/类
@Test
public void testPlusMatch() {
RegAut aut = createAutomaton("next+");
Set<Result> results = new HashSet<>();
addRelated(results, nC1, nC2);
addRelated(results, nC1, nC3);
addRelated(results, nC1, nC4);
assertEquals(results, aut.getMatches(testGraph, nC1, null));
assertEquals(results, aut.getMatches(testGraph, nC1, null));
results.clear();
addRelated(results, nC2, nC3);
addRelated(results, nC2, nC4);
assertEquals(results, aut.getMatches(testGraph, nC2, null));
assertEquals(results, aut.getMatches(testGraph, nC2, null));
results.clear();
addRelated(results, nC1, nC3);
addRelated(results, nC2, nC3);
assertEquals(results, aut.getMatches(testGraph, null, nC3));
assertEquals(results, aut.getMatches(testGraph, null, nC3));
aut = createAutomaton("?.2");
results.clear();
addRelated(results, nI2, nI2);
addRelated(results, nI3, nI2);
addRelated(results, nC2, nI2);
}
示例10: visitSet
import java.util.Set; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
protected void visitSet(Set setVal) {
Set newContent = new LinkedHashSet();
boolean entriesModified = false;
for (Object elem : setVal) {
int elemHash = (elem != null ? elem.hashCode() : 0);
Object newVal = resolveValue(elem);
int newValHash = (newVal != null ? newVal.hashCode() : 0);
newContent.add(newVal);
entriesModified = entriesModified || (newVal != elem || newValHash != elemHash);
}
if (entriesModified) {
setVal.clear();
setVal.addAll(newContent);
}
}
示例11: run
import java.util.Set; //导入方法依赖的package包/类
public void run() throws IOException {
Selector selector = Selector.open();
// will register the socket on the selector
TunnelServer tunnelServer = new TunnelServer(port, selector);
Log.i(TAG, "Relay server started");
long nextCleaningDeadline = System.currentTimeMillis() + UDPConnection.IDLE_TIMEOUT;
while (true) {
long timeout = Math.max(0, nextCleaningDeadline - System.currentTimeMillis());
selector.select(timeout);
Set<SelectionKey> selectedKeys = selector.selectedKeys();
long now = System.currentTimeMillis();
if (now >= nextCleaningDeadline) {
tunnelServer.cleanUp();
nextCleaningDeadline = now + CLEANING_INTERVAL;
} else if (selectedKeys.isEmpty()) {
throw new AssertionError("selector.select() returned without any event, an invalid SelectionKey was probably been registered");
}
for (SelectionKey selectedKey : selectedKeys) {
SelectionHandler selectionHandler = (SelectionHandler) selectedKey.attachment();
selectionHandler.onReady(selectedKey);
}
// by design, we handled everything
selectedKeys.clear();
}
}
示例12: clearThreadAllCheckpoints
import java.util.Set; //导入方法依赖的package包/类
private void clearThreadAllCheckpoints( String threadName ) {
Set<CheckpointInfo> set = checkpointsPerThread.get(threadName);
if (set != null) {
set.clear();
} else { // initialize - put empty set
set = new HashSet<CheckpointInfo>();
checkpointsPerThread.put(threadName, set);
}
}
示例13: clearJCells
import java.util.Set; //导入方法依赖的package包/类
/** Clears the inverse mapping from labels to {@link JCell}s. */
public void clearJCells() {
for (Set<JCell<G>> jCellSet : this.entryJCellMap.values()) {
jCellSet.clear();
}
this.jCellEntryMap.clear();
}
示例14: createVersusClear
import java.util.Set; //导入方法依赖的package包/类
static public void createVersusClear(boolean create) {
Set<Integer> testSet = new HashSet<>();
for (int i = 0; i < CREATE_TRY_COUNT; i++) {
if (create) {
CREATE.start();
testSet = new HashSet<>();
CREATE.stop();
} else {
CLEAR.start();
testSet.clear();
CLEAR.stop();
}
testSet.addAll(elementSet);
}
}
示例15: run
import java.util.Set; //导入方法依赖的package包/类
@Override
public void run() {
final Selector tSelector = this.selector;
for (;;) {
++connectCount;
try {
// 查看有无连接就绪 阻塞的
tSelector.select(1000L);
connect(tSelector);
Set<SelectionKey> keys = tSelector.selectedKeys();
try {
for (SelectionKey key : keys) {
Object att = key.attachment();
if (att != null && key.isValid() && key.isConnectable()) {
finishConnect(key, att);
} else {
key.cancel();
}
}
} finally {
keys.clear();
}
} catch (Exception e) {
LOGGER.warn(name, e);
}
}
}