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


Java TObjectIntHashMap.put方法代码示例

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


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

示例1: collectAllItinClasses

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
/**
 * Gathers and enumerates all the itinerary classes.
 * Returns itinerary class count.
 * @param os
 * @param itinClassesMap
 * @return
 */
private int collectAllItinClasses(PrintStream os, TObjectIntHashMap<String> itinClassesMap)
        throws Exception
{
    ArrayList<Record> itinClassList = records.getAllDerivedDefinition("InstrItinClass");

    itinClassList.sort(LessRecord);

    // for each itinenary class.
    int n = itinClassList.size();
    for (int i = 0; i < n; i++)
    {
        Record itinClass = itinClassList.get(i);
        itinClassesMap.put(itinClass.getName(), i);
    }

    return n;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:25,代码来源:SubtargetEmitter.java

示例2: findDepVarsOf

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
private void findDepVarsOf(TreePatternNode node, TObjectIntHashMap<String> depMap)
{
    if (node.isLeaf())
    {
        if (node.getLeafValue() instanceof DefInit)
        {
            if (depMap.containsKey(node.getName()))
                depMap.put(node.getName(), depMap.get(node.getName()) + 1);
            else
                depMap.put(node.getName(), 1);
        }
    }
    else
    {
        for (int i = 0, e = node.getNumChildren(); i != e; i++)
            findDepVarsOf(node.getChild(i), depMap);
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:CodeGenDAGPatterns.java

示例3: extractData

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
@Override
public TObjectIntHashMap<ItemVO<Integer, Integer>> extractData(ResultSet rs) {
    TObjectIntHashMap<ItemVO<Integer, Integer>> map = new TObjectIntHashMap<>();
    int itemId, itemTypeId, tenantId, cnt = 0;

    try {
        while (rs.next()) {
            itemId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_COLUMN_NAME);
            itemTypeId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_TYPE_COLUMN_NAME);
            tenantId = rs.getInt(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME);
            cnt = rs.getInt("cnt");
            map.put(new ItemVO<>(tenantId, itemId, itemTypeId), cnt);
        }
        // optimization: replaces former adjustSupport method
        minSupp = cnt;
    } catch (SQLException e) {
        logger.error("An error occured during ResultSet extraction", e);
        throw new RuntimeException(e);
    }
    return map;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:22,代码来源:AggregatorActionDAOMysqlImpl.java

示例4: extractData

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public TObjectIntHashMap<ItemVO<Integer, Integer>> extractData(ResultSet rs) {
    TObjectIntHashMap<ItemVO<Integer, Integer>> map = new TObjectIntHashMap<ItemVO<Integer, Integer>>();
    int itemId, itemTypeId, tenantId, cnt = 0;

    try {
        while (rs.next()) {
            itemId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_COLUMN_NAME);
            itemTypeId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_TYPE_COLUMN_NAME);
            tenantId = rs.getInt(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME);
            cnt = rs.getInt("cnt");
            map.put(new ItemVO<Integer, Integer>(tenantId, itemId, itemTypeId), cnt);
        }
        // optimization: replaces former adjustSupport method
        minSupp = cnt;
    } catch (SQLException e) {
        logger.error("An error occured during ResultSet extraction", e);
        throw new RuntimeException(e);
    }
    return map;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:RuleminingActionDAOMysqlImpl.java

示例5: testCollectPubDates

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
@Test
public void testCollectPubDates() throws Exception {
  final List<ScoredDocument> fakeData = mkRankedList(
      SD("doc0", 1.0),
      SD("doc-missing", 0.5),
      SD("doc1", 0.3)
  );
  Assert.assertEquals(3, fakeData.size());

  TObjectIntHashMap<String> pubdates = new TObjectIntHashMap<String>();
  pubdates.put("doc17", 1777);
  pubdates.put("doc0", 1888);
  pubdates.put("doc1", 1999);

  List<ScoredDate> dates = ExtractDates.toDates(ExtractDates.collectPubDates(fakeData, pubdates));

  Assert.assertEquals(2, dates.size());

  Assert.assertEquals(1.0, dates.get(0).score, 0.001);
  Assert.assertEquals(0.3, dates.get(1).score, 0.001);

  Assert.assertEquals(1888, dates.get(0).year);
  Assert.assertEquals(1999, dates.get(1).year);
}
 
开发者ID:jjfiv,项目名称:ecir2015timebooks,代码行数:25,代码来源:ExtractDatesTest.java

示例6: loadIndex

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public static void loadIndex(String file, TObjectIntHashMap<String> value_id){
	
	if(new File(file).exists()){
		try{
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = null;
			int index = 1;
			while((line=br.readLine()) != null){
				String[] vals = line.split("\t");
				if(vals.length>1)
					value_id.put(vals[1], Integer.parseInt(vals[0]));
				else
					value_id.put(vals[0], index++);
			}
			
			br.close();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:24,代码来源:TextFileUtils.java

示例7: computeIndex

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public static void computeIndex(String file, TObjectIntHashMap<String> value_id,
		HashSet<String> labels){
	
	
	if(new File(file).exists()){
		try{
			BufferedReader br = new BufferedReader(new FileReader(file));
			String line = null;
			int index = 1;
			while((line=br.readLine()) != null){
				String[] vals = line.split("\t");
				
				for(String s : labels){
					value_id.put(s + "-" + vals[0], index++);
					value_id.put(s + "-inv_" + vals[0], index++);
				}
			}
			
			br.close();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:27,代码来源:TextFileUtils.java

示例8: readObject

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException
  {
//    in.defaultReadObject ();
    int version = in.readInt ();  // version

    int numVariables = in.readInt ();
    var2idx = new TObjectIntHashMap (numVariables);
    for (int vi = 0; vi < numVariables; vi++) {
      Variable var = (Variable) in.readObject ();
      var2idx.put (var, vi);
    }

    int numRows = in.readInt ();
    values = new ArrayList (numRows);
    for (int ri = 0; ri < numRows; ri++) {
      Object[] row = (Object[]) in.readObject ();
      values.add (row);
    }

    scale = (version >= 2) ? in.readDouble () : 1.0;
  }
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:22,代码来源:Assignment.java

示例9: readObject

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
    lock = new ReentrantReadWriteLock();
    lock.writeLock().lock();
    try {
        int version = in.readInt();
        int size = in.readInt();
        entries = new ArrayList(size);
        map = new TObjectIntHashMap(size);
        for (int i = 0; i < size; i++) {
            Object o = in.readObject();
            map.put(o, i);
            entries.add(o);
        }
        growthStopped = in.readBoolean();
        entryClass = (Class) in.readObject();
        if (version > 0) { // instanced id added in version 1S
            instanceId = (VMID) in.readObject();
        }
    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:23,代码来源:Alphabet.java

示例10: StrippedPartition

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public StrippedPartition(String[] columnContent) {
	TObjectIntHashMap<String> valueToIndex = new TObjectIntHashMap<>();
	LinkedHashMap<Integer, TEquivalence> helpMap = new LinkedHashMap<>();
	
	for (int rowIndex = 0; rowIndex < columnContent.length; rowIndex++) {
		String value = columnContent[rowIndex];
		// if the value wasn't there yet, the row index becomes the representative 
		// for that equivalence class
		if (!valueToIndex.containsKey(value)) {
			valueToIndex.put(value, rowIndex);
			TEquivalence equivalenceGroup = new EquivalenceGroupTIntHashSet();
			equivalenceGroup.add(rowIndex);
			helpMap.put(rowIndex, equivalenceGroup);
		} 
		// otherwise find the right equivalence class and add the current element index
		else {
			int equivalenceGroupIndex = valueToIndex.get(value);
			TEquivalence equivalenceClass = helpMap.get(equivalenceGroupIndex);
			equivalenceClass.add(rowIndex);
		}
	}
	// remove equivalence classes with only one element
	for(Iterator<Map.Entry<Integer, TEquivalence>> it=helpMap.entrySet().iterator(); it.hasNext();) {
	     Map.Entry<Integer, TEquivalence> entry = it.next();
	     if (entry.getValue().size() <= 1) {
	          it.remove();
	     }
	 }

	// sort the stripped partition by equivalence group sizes
	this.addAll(helpMap.values());
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:33,代码来源:StrippedPartition.java

示例11: testPutIfAbsent

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public void testPutIfAbsent() {
    TObjectIntHashMap<String> map = new TObjectIntHashMap<String>();

    map.put( "One", 1 );
    map.put( "Two", 2 );
    map.put( "Three", 3 );

    assertEquals( 1, map.putIfAbsent( "One", 2 ) );
    assertEquals( 1, map.get( "One" ) );
    assertEquals( 0, map.putIfAbsent( "Nine", 9 ) );
    assertEquals( 9, map.get( "Nine" ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:13,代码来源:TObjectPrimitiveMapDecoratorTest.java

示例12: testToString

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public void testToString() {
    TObjectIntHashMap<String> m = new TObjectIntHashMap<String>();
    m.put( "One", 11 );
    m.put( "Two", 22 );

    String to_string = m.toString();
    assertTrue( to_string, to_string.equals( "{One=11,Two=22}" )
                           || to_string.equals( "{Two=22,One=11}" ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:10,代码来源:TObjectPrimitiveMapDecoratorTest.java

示例13: count

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
@Override
public void count(ItemVO<Integer, Integer> item1, ItemVO<Integer, Integer> item2)
        throws Exception {
    ItemVO<Integer, Integer> mainKey, subKey;
    TObjectIntHashMap<ItemVO<Integer, Integer>> set;

    if (item1.getItem() < item2.getItem()) {
        mainKey = item1;
        subKey = item2;
    } else {
        mainKey = item2;
        subKey = item1;
    }

    set = map.get(mainKey);
    if (set == null) {
        set = new TObjectIntHashMap<ItemVO<Integer, Integer>>();
        map.put(mainKey, set);
    }

    Integer cnt = set.get(subKey);
    if (cnt == null) {
        counter++;
        cnt = 1;
    } else {
        cnt++;
    }
    set.put(subKey, cnt);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:30,代码来源:TupleCounterMemoryTroveImpl.java

示例14: getSearchResults

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
/**
 * Get the search results by the words submitted, aggregating each word's resulting ids and ordering those resulting id's by result weight.
 * 
 * @param words The set of words to get the search results for.
 *  
 * @return A set containing the matched search results up to the specified limit
 */
public TObjectIntHashMap<String> getSearchResults(Set<String> words) {

	TLongIntHashMap longResults = super.getSearchResults(this, words);
	TObjectIntHashMap<String> stringResults = new TObjectIntHashMap<String>();

	long[] longResultKeys = longResults.keys();
	int[] longResultValues = longResults.values();

	for (int i = 0; i < longResultKeys.length; i++) {
		stringResults.put(stringLookupMap.get(((Long) longResultKeys[i]).intValue()), longResultValues[i]);
	}
	return stringResults;
}
 
开发者ID:networkdowntime,项目名称:EmbeddableSearch,代码行数:21,代码来源:UnigramStringSearchHistogram.java

示例15: getSearchResults

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
/**
 * Get the search results by the words submitted, aggregating each word's resulting ids and ordering those resulting id's by result weight.
 * 
 * @param searchTerms The set of words to get the search results for
 * @return A set containing the matched search results up to the specified limit
 */
public TObjectIntHashMap<String> getSearchResults(Set<String> searchTerms, int weightMultiplier) {

	TLongIntHashMap longResults = super.getResultsRaw(searchTerms, weightMultiplier);
	TObjectIntHashMap<String> results = new TObjectIntHashMap<String>();

	long[] longResultKeys = longResults.keys();
	int[] longResultValues = longResults.values();

	for (int i = 0; i < longResultKeys.length; i++) {
		results.put(stringLookupMap.get((int) longResultKeys[i]), longResultValues[i]);
	}
	return results;
}
 
开发者ID:networkdowntime,项目名称:EmbeddableSearch,代码行数:20,代码来源:DigramStringSearchHistogram.java


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