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


Java TreeMap.clear方法代码示例

本文整理汇总了Java中java.util.TreeMap.clear方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMap.clear方法的具体用法?Java TreeMap.clear怎么用?Java TreeMap.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.TreeMap的用法示例。


在下文中一共展示了TreeMap.clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toTreeMap

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * 将nmap对象转换为object到目标map
 * 目标map将被清空
 * @param nmap
 * @param map
 */
public final void toTreeMap(NMap nmap,TreeMap<Object,Object> map)
{
	map.clear();
	Set<Entry<NType<?>, NType<?>>> set=nmap.entrySet();
	for(Entry<NType<?>, NType<?>> kv:set)
	{
		map.put(toTreeMapObject(kv.getKey()),toTreeMapObject(kv.getValue()));
	}
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:16,代码来源:NMapConvert.java

示例2: storeGroupSelection

import java.util.TreeMap; //导入方法依赖的package包/类
private boolean storeGroupSelection(TableViewer tableViewer, TreeMap<Integer, List<List<Integer>>> groupSelectionMap){
	
	boolean retVal=false;
	List<List<Integer>> grpList = new ArrayList<>();
	List<Integer> selectionList = new ArrayList<>();
	
	TableItem[] items = tableViewer.getTable().getItems();
	
	for (TableItem tableItem : items) {
		Button button = (Button) tableItem.getData(GROUP_CHECKBOX);
		if(button.getSelection()){
			selectionList.add(tableViewer.getTable().indexOf(tableItem));
		}
	}
		
	if (groupSelectionMap.isEmpty()) {
		grpList.add(selectionList);
		groupSelectionMap.put(0, grpList);
		retVal=true;
	} else {
		if (FilterHelper.INSTANCE.validateUserGroupSelection(groupSelectionMap, selectionList)) {
			if(FilterHelper.INSTANCE.isColumnModifiable(groupSelectionMap, selectionList)){
				retVal=true;
			}else{
				grpList.add(selectionList);
				Map<Integer, List<List<Integer>>> tempMap = new TreeMap<>();
				tempMap.putAll(groupSelectionMap);
				groupSelectionMap.clear();
				groupSelectionMap.put(0, grpList);
				for (int i = 0; i < tempMap.size(); i++) {
					groupSelectionMap.put(i + 1, tempMap.get(i));
				}
				retVal=true;
				FilterHelper.INSTANCE.rearrangeGroups(groupSelectionMap, selectionList);
			}
		} 
	}
	return retVal;  
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:40,代码来源:FilterConditionsDialog.java

示例3: testEquals

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * Maps with same contents are equal
 */
public void testEquals() {
    TreeMap map1 = map5();
    TreeMap map2 = map5();
    assertEquals(map1, map2);
    assertEquals(map2, map1);
    map1.clear();
    assertFalse(map1.equals(map2));
    assertFalse(map2.equals(map1));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TreeMapTest.java

示例4: generateSmallBundles

import java.util.TreeMap; //导入方法依赖的package包/类
/***
 * If intents, entities and dialogs size exceeds size 300 then create smaller
 * bundles on GP
 * 
 * @param uniqueBotOutput
 * @param splitSize
 * @param bundleName
 * @param newBundleData
 * @param uniqueBotOutputEntities
 * @return
 * @throws ServiceException
 */
private void generateSmallBundles(Map<String, TreeSet<String>> uniqueBotOutput, int splitSize, String bundleName,
    NewBundleData newBundleData) throws ServiceException {
  int counter = 1;
  int batch = 1;
  TreeMap<String, TreeSet<String>> newIntentMap = new TreeMap<String, TreeSet<String>>();
  String newBundlename = null;
  for (Entry<String, TreeSet<String>> entry : uniqueBotOutput.entrySet()) {

    TreeSet<String> newIntentSet = entry.getValue();
    String key = entry.getKey();
    newIntentMap.put(key, newIntentSet);

    if (counter == splitSize) {
      newBundlename = bundleName + "-" + batch;
      // Create Bundle on GP
      getGPClient().createBundle(newBundlename, newBundleData);
      System.out.println("Created " + newBundlename);

      // Upload Resource Strings to Intents
      if (newBundlename.contains("-dialogs") || newBundlename.contains("-intents")) {
        uploadToGP(newBundlename, newIntentMap);
      } else {
        uploadEntities(newBundlename, newIntentMap);
      }
      batch++;
      newBundlename = null;
      newIntentMap.clear();
      counter = 0;
    }
    counter++;
  }
  // Handle last bucket
  if (newIntentMap.size() > 0) {
    newBundlename = bundleName + "-" + batch;
    getGPClient().createBundle(newBundlename, newBundleData);
    System.out.println("Created " + newBundlename);
    // Upload Resource Strings
    if (newBundlename.contains("-dialogs") || newBundlename.contains("-intents")) {
      uploadToGP(newBundlename, newIntentMap);
    } else {
      uploadEntities(newBundlename, newIntentMap);
    }
  }
}
 
开发者ID:IBM-Cloud,项目名称:gp-watson-conversation,代码行数:57,代码来源:WCS_To_GP.java

示例5: operateOnTx

import java.util.TreeMap; //导入方法依赖的package包/类
@Override
protected boolean operateOnTx(TXId txId, DistributionManager dm) throws RemoteOperationException {
  GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
  TXManagerImpl txMgr = cache.getTXMgr();

  if (logger.isDebugEnabled()) {
    logger.debug("DistTXPrecommitMessage.operateOnTx: Tx {} with Secondaries List {}", txId,
        this.secondaryTransactionalOperations);
  }

  // should not be commited before
  assert (!txMgr.isHostedTxRecentlyCompleted(txId));
  // @see TXCommitMessage.process(DistributionManager)
  TXLockService.createDTLS(); // fix bug 38843; no-op if already created
  final TXStateProxy txStateProxy = txMgr.getTXState();
  boolean precommitSuccess = true;
  TreeMap<String, ArrayList<DistTxThinEntryState>> entryStateSortedMap =
      new TreeMap<String, ArrayList<DistTxThinEntryState>>();
  // [DISTTX] TODO - Test valid scenarios of null txState
  // if no TXState was created (e.g. due to only getEntry/size operations
  // that don't start remote TX) then ignore
  if (txStateProxy != null) {
    if (!txStateProxy.isDistTx() || !txStateProxy.isTxStateProxy()
        || txStateProxy.isCreatedOnDistTxCoordinator()) {
      throw new UnsupportedOperationInTransactionException(
          LocalizedStrings.DISTTX_TX_EXPECTED.toLocalizedString("DistTXStateProxyImplOnDatanode",
              txStateProxy.getClass().getSimpleName()));
    }

    ((DistTXStateProxyImplOnDatanode) txStateProxy).setPreCommitMessage(this);

    /*
     * Perform precommit
     * 
     * [DISTTX] Handle different exceptions here
     */
    txMgr.precommit();
    precommitSuccess = ((DistTXStateProxyImplOnDatanode) txStateProxy).getPreCommitResponse();
    if (precommitSuccess) {
      precommitSuccess = ((DistTXStateProxyImplOnDatanode) txStateProxy)
          .populateDistTxEntryStateList(entryStateSortedMap);
      if (!precommitSuccess) {
        entryStateSortedMap.clear();
        if (logger.isDebugEnabled()) {
          logger.debug("DistTXPrecommitMessage.operateOnTx: Tx {} Failed while creating response",
              txId);
        }
      }
    } else {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "DistTXPrecommitMessage.operateOnTx: Tx {} Failed while applying changes for replicates",
            txId);
      }
    }
  }

  // Send Response : Send false if conflict
  DistTxPrecommitResponse finalResponse = new DistTxPrecommitResponse(precommitSuccess,
      new ArrayList<ArrayList<DistTxThinEntryState>>(entryStateSortedMap.values()));
  DistTXPrecommitReplyMessage.send(getSender(), getProcessorId(), finalResponse,
      getReplySender(dm));

  // return false so there isn't another reply
  return false;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:67,代码来源:DistTXPrecommitMessage.java

示例6: testClear

import java.util.TreeMap; //导入方法依赖的package包/类
/**
 * clear removes all pairs
 */
public void testClear() {
    TreeMap map = map5();
    map.clear();
    assertEquals(0, map.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TreeMapTest.java


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