当前位置: 首页>>代码示例>>Java>>正文


Java Set.clear方法代码示例

本文整理汇总了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();
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:20,代码来源:ConfusionMatrix.java

示例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;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:FsDatasetAsyncDiskService.java

示例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));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:22,代码来源:SortedSetCommandsTest.java

示例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());
	}
}
 
开发者ID:lagodiuk,项目名称:spoj,代码行数:26,代码来源:ACMAKER.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:X509CertSelectorTest.java

示例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();
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:17,代码来源:ClassFeatureExtractor.java

示例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");
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:DebugTrace.java

示例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);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:26,代码来源:AbstractAutomatonTest.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:BeanDefinitionVisitor.java

示例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();
    }
}
 
开发者ID:Genymobile,项目名称:gnirehtet,代码行数:31,代码来源:Relay.java

示例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);
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:11,代码来源:LoadQueuesState.java

示例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();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:8,代码来源:LabelFilter.java

示例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);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:16,代码来源:HashSpeedTest.java

示例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);
		}
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:28,代码来源:NIOConnector.java


注:本文中的java.util.Set.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。