本文整理汇总了Java中gnu.trove.map.hash.THashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java THashMap.put方法的具体用法?Java THashMap.put怎么用?Java THashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.hash.THashMap
的用法示例。
在下文中一共展示了THashMap.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public THashMap<String, String> read(long n){
THashMap<String,String> res = new THashMap<String,String>();
long count = 0;
for(String key : file_index.keySet()){
if(count < n){
String tmp = read(key);
res.put(key, tmp);
count++;
}
else
break;
}
return res;
}
示例2: readFileIndex
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
private THashMap<String, String> readFileIndex(){
THashMap<String,String> file_index = new THashMap<String,String>();
try{
String line = null;
while((line=file_index_reader.readLine()) != null){
String[] vals = line.split("\t");
file_index.put(vals[0], vals[1]+":"+vals[2]);
index_size++;
}
return file_index;
}
catch(Exception e){
e.printStackTrace();
}
return null;
}
示例3: loadFileIndex
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public static void loadFileIndex(String file, THashMap<String, String> items_pair_value){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
items_pair_value.put(vals[0], vals[1]+":"+vals[2]);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例4: EdgesIterator
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public EdgesIterator (ACRF.UnrolledGraph acrf, Assignment observed)
{
this.graph = acrf;
this.observed = observed;
cliquesByEdge = new THashMap();
for (Iterator it = acrf.unrolledVarSetIterator (); it.hasNext();) {
ACRF.UnrolledVarSet clique = (ACRF.UnrolledVarSet) it.next ();
for (int v1idx = 0; v1idx < clique.size(); v1idx++) {
Variable v1 = clique.get(v1idx);
List adjlist = graph.allFactorsContaining (v1);
for (Iterator factorIt = adjlist.iterator(); factorIt.hasNext();) {
Factor factor = (Factor) factorIt.next ();
if (!cliquesByEdge.containsKey (factor)) { cliquesByEdge.put (factor, new ArrayList()); }
List l = (List) cliquesByEdge.get (factor);
if (!l.contains (clique)) { l.add (clique); }
}
}
}
cursor = cliquesByEdge.keySet().iterator ();
}
示例5: setupLabel2Var
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
private void setupLabel2Var ()
{
idx2var = new Variable [lblseq.size ()][];
var2label = new THashMap();
for (int t = 0; t < lblseq.size (); t++) {
Labels lbls = lblseq.getLabels (t);
idx2var[t] = new Variable [lbls.size ()];
for (int j = 0; j < lbls.size (); j++) {
Label lbl = lbls.get (j);
Variable var = new Variable (lbl.getLabelAlphabet ());
var.setLabel ("I"+id+"_VAR[f=" + j + "][tm=" + t + "]");
idx2var[t][j] = var;
var2label.put (var, lbl);
}
}
}
示例6: Record
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public Record (String name, LabeledSpans spans) {
this.name = name;
fieldMap = new THashMap ();
for (int i = 0; i < spans.size(); i++) {
LabeledSpan span = spans.getLabeledSpan (i);
if (!span.isBackground()) {
Label tag = span.getLabel ();
Field field = (Field) fieldMap.get (tag);
if (field == null) {
field = new Field (span);
fieldMap.put (tag, field);
} else {
field.addFiller (span);
}
}
}
}
示例7: readDataSetFile
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
private static void readDataSetFile(List<DataSetFileEntry> _data) {
features_frequencies_per_class = new THashMap();
records_count = _data.size();
for (DataSetFileEntry line_entry : _data) {
classes_frequencies.increment(line_entry.class_name, 1);
for (String feature_name : line_entry.features.keySet()) {
// the value of the feature is either 1 or nothing ////FIXME this part I am not sure about
int feature_val = line_entry.features.get(feature_name).intValue();
CustomStringIntHashMap feature_map;
if (features_frequencies_per_class.containsKey(feature_name)) {
feature_map = features_frequencies_per_class.get(feature_name);
} else {
feature_map = new CustomStringIntHashMap();
features_frequencies_per_class.put(feature_name, feature_map);
}
feature_map.increment(line_entry.class_name, feature_val);
features_frequencies.increment(feature_name, feature_val);
}
}
all_features_count = features_frequencies.size();
all_classes_count = classes_frequencies.size();
}
示例8: parse
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public THashMap<String, String> parse(String[] input) {
THashMap<String, String> result = new THashMap<>();
try {
CommandLine cmdLine = this.parse(this.getOptions(), input);
for (Option option : cmdLine.getOptions()) {
result.put(option.getOpt(), option.getValue());
}
} catch (ParseException e) {
e.printStackTrace();
}
return result;
}
示例9: toXmlDocument
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public Document toXmlDocument (String rootEltName, Namespace ns)
{
ArrayList orderedByStart = new ArrayList (extractedSpans);
Collections.sort (orderedByStart, new Comparator () {
public int compare (Object o, Object o1)
{
int start1 = ((Span)o).getStartIdx ();
int start2 = ((Span)o1).getStartIdx ();
return Double.compare (start1, start2);
}
} );
ArrayList roots = new ArrayList (orderedByStart);
THashMap children = new THashMap ();
for (int i = 0; i < orderedByStart.size(); i++) {
LabeledSpan child = (LabeledSpan) orderedByStart.get (i);
for (int j = i-1; j >= 0; j--) {
LabeledSpan parent = (LabeledSpan) orderedByStart.get (j);
if (parent.isSubspan (child)) {
List childList = (List) children.get (parent);
if (childList == null) {
childList = new ArrayList ();
children.put (parent, childList);
}
roots.remove (child);
childList.add (child);
break;
}
}
}
CharSequence doc = (CharSequence) document;
Span wholeDoc = new StringSpan (doc, 0, doc.length ());
return new Document (generateElement (rootEltName, wholeDoc, roots, children));
}
示例10: testCompact
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public void testCompact() throws Exception {
THashMap<Integer,Integer> map = new THashMap<Integer,Integer>();
Integer[] data = new Integer[1000];
for (int i = 0; i < 1000; i++) {
data[i] = new Integer(i);
map.put(data[i], data[i]);
}
assertTrue(map._maxSize > 1000);
for (int i = 0; i < 1000; i+=2) {
// try {
map.remove(data[i]);
// }
// catch( RuntimeException ex ) {
// System.err.println("Error on i: " + i);
// System.out.println("Hash codes:");
// for( int j = 0 ; j < data.length; j++ ) {
// if ( ( j % 8 ) == 0 ) {
// System.out.println(",");
// }
// else System.out.print(",");
// System.out.print(map._hashingStrategy.computeHashCode(data[j]));
// }
//
//
// System.out.println("Remove:");
// for( int j = 0 ; j <= i; j+=2 ) {
// if ( ( j % 8 ) == 0 ) {
// System.out.println(",");
// }
// else System.out.print(",");
// System.out.print(map._hashingStrategy.computeHashCode(data[j]));
// }
// throw ex;
// }
}
assertEquals(500, map.size());
map.compact();
assertEquals(500, map.size());
assertTrue(map._maxSize < 1000);
}
示例11: testCompact
import gnu.trove.map.hash.THashMap; //导入方法依赖的package包/类
public void testCompact() throws Exception {
THashMap<Integer,Integer> map = new THashMap<Integer,Integer>();
Integer[] data = new Integer[1000];
for (int i = 0; i < 1000; i++) {
data[i] = new Integer(i);
map.put(data[i], data[i]);
}
assertTrue(map._maxSize > 1000);
for (int i = 0; i < 1000; i+=2) {
// try {
map.remove(data[i]);
// }
// catch( RuntimeException ex ) {
// System.err.println("Error on i: " + i);
// System.out.println("Hash codes:");
// for( int j = 0 ; j < data.length; j++ ) {
// if ( ( j % 8 ) == 0 ) {
// System.out.println(",");
// }
// else System.out.print(",");
// System.out.print(map._hashingStrategy.computeHashCode(data[j]));
// }
//
//
// System.out.println("Remove:");
// for( int j = 0 ; j <= i; j+=2 ) {
// if ( ( j % 8 ) == 0 ) {
// System.out.println(",");
// }
// else System.out.print(",");
// System.out.print(map._hashingStrategy.computeHashCode(data[j]));
// }
// throw ex;
// }
}
assertEquals(500, map.size());
map.compact();
assertEquals(500, map.size());
assertTrue(map._maxSize < 1000);
}