本文整理汇总了Java中gnu.trove.map.hash.TIntIntHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TIntIntHashMap.put方法的具体用法?Java TIntIntHashMap.put怎么用?Java TIntIntHashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.hash.TIntIntHashMap
的用法示例。
在下文中一共展示了TIntIntHashMap.put方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadInputMetadataID
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
public static void loadInputMetadataID(String metadata_file_index, String input_uri,
TIntIntHashMap input_metadata_id){
TObjectIntHashMap<String> metadata_index = new TObjectIntHashMap<String>();
loadIndex(metadata_file_index, metadata_index);
try{
BufferedReader br = new BufferedReader(new FileReader(input_uri));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
if(metadata_index.containsKey(vals[1]));
input_metadata_id.put(Integer.parseInt(vals[0]), metadata_index.get(vals[1]));
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例2: addBranches
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
@Override
public void addBranches(String key, int value){
if (!this.branches.containsKey(key))
this.branches.put(key, new TIntIntHashMap());
if(this.branches.get(key)!=null){
if(this.branches.get(key).containsKey(value)){
if(this.branches.get(key).get(value) < Integer.MAX_VALUE)
this.branches.get(key).adjustValue(value, 1);
}
else
this.branches.get(key).put(value, 1);
}
else{
TIntIntHashMap tmp = new TIntIntHashMap();
tmp.put(value, 1);
this.branches.put(key, tmp);
}
}
示例3: removeFromVariableCaches
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private void removeFromVariableCaches (Variable victim)
{
Set survivors = new THashSet(variablesSet ());
survivors.remove (victim);
int vi = 0;
TIntIntHashMap dict = new TIntIntHashMap (survivors.size ());
// dict.setDefaultValue (-1); No longer supported, but this.getIndex() written to avoid need for this.
my2global = new int[survivors.size ()];
for (Iterator it = survivors.iterator (); it.hasNext();) {
Variable var = (Variable) it.next ();
int gvi = var.getIndex ();
dict.put (gvi, vi);
my2global [vi] = gvi;
}
projectionMap = dict;
numNodes--; // do this at end b/c it affects getVertexSet()
}
示例4: commuteInstruction
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private boolean commuteInstruction(
OutParamWrapper<Integer> mi,
MachineBasicBlock mbb,
int regC,
int dist,
TIntIntHashMap distanceMap)
{
MachineInstr newMI = tii.commuteInstruction(mbb.getInstAt(mi.get()));
if (newMI== null)
{
return false;
}
if (!newMI.equals(mbb.getInstAt(mi.get())))
{
if (lv != null)
lv.replaceKillInstruction(regC, mbb.getInstAt(mi.get()), newMI);
mbb.insert(mi.get(), newMI);
mbb.remove(mi.get());
mi.set(newMI.index());
distanceMap.put(newMI.index(), dist);
}
return true;
}
示例5: runOnMachineFunction
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
@Override
public boolean runOnMachineFunction(MachineFunction mf)
{
this.mf = mf;
ec = new IntEqClasses(mf.getNumBlockIDs()*2);
for (MachineBasicBlock mbb : mf.getBasicBlocks())
{
int outEdge = mbb.getNumber()*2 + 1;
// Join the outgoing
for (Iterator<MachineBasicBlock> itr = mbb.succIterator(); itr.hasNext(); )
{
ec.join(outEdge, itr.next().getNumber()*2);
}
}
blocks = new TIntArrayList[getNumBundles()];
for (int i = 0, e; i < getNumBundles(); i++)
blocks[i] = new TIntArrayList();
groupID = new TIntIntHashMap();
for (int i = 0; i < ec.getNumIds(); i++)
{
int leading = ec.findLeader(i);
if (!groupID.containsKey(leading))
groupID.put(leading, nextID++);
}
for (int i = 0, e = mf.getNumBlockIDs(); i < e; i++)
{
int b0 = getBundles(i, false);
int b1 = getBundles(i, true);
blocks[b0].add(i);
if (b1 != b0)
blocks[b1].add(i);
}
nextID = 0;
return false;
}
示例6: merge
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private void merge(TIntIntHashMap linked, int start, int target) {
if (start == target)
return;
final int old = linked.get(start);
if (old > target) {
linked.put(start, target);
merge(linked, old, target);
} else {
merge(linked, target, old);
}
}
示例7: getCharWidth
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private static int getCharWidth(Font font, char ch, TIntIntHashMap map) {
int width = map.get(ch);
if (width == 0) {
width = Fonts.getFontMetrics(font).charWidth(ch);
if (width == 0) {
width = 1;
}
map.put(ch, width);
}
return width;
}
示例8: TroveNdx
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
public TroveNdx(int[] keys)
{
int nkey = keys.length;
_keyndx = new TIntIntHashMap(nkey, 0.5f, -1, -1);
for(int i=0; i < nkey; ++i)
_keyndx.put(keys[i], i);
_keys = keys.clone();
}
示例9: buildIndexMap
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
private void buildIndexMap(List<Row> rows) {
Collections.sort(rows);
indexMap = new TIntIntHashMap(Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR, -1, -1);
for (int i = 0; i < rows.size(); i++) {
Row row = rows.get(i);
indexMap.put(row.idx, i);
}
}
示例10: writeBinary
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
@Override
public byte[] writeBinary(Mesh mesh) throws IOException {
final int vertexBytes = 3 * 4 + 3 * 4 + 3 * 4;
final int triangleBytes = 3 * 4 + 1;
final String header = "ply\nformat binary_little_endian 1.0\ncomment This binary PLY mesh was created with imagej-mesh.\n";
final String vertexHeader = "element vertex " + mesh.getVertices().size() + "\nproperty float x\nproperty float y\nproperty float z\nproperty float nx\nproperty float ny\nproperty float nz\nproperty float r\n property float g\n property float b\n";
final String triangleHeader = "element face " + mesh.getTriangles().size() + "\nproperty list uchar int vertex_index\n";
final String endHeader = "end_header\n";
final int bytes = header.getBytes().length + vertexHeader.getBytes().length + triangleHeader.getBytes().length + endHeader.getBytes().length + mesh.getVertices().size() * vertexBytes + mesh.getTriangles().size() * triangleBytes;
final ByteBuffer buffer = ByteBuffer.allocate(bytes).order(
ByteOrder.LITTLE_ENDIAN);
buffer.put(header.getBytes());
buffer.put(vertexHeader.getBytes());
buffer.put(triangleHeader.getBytes());
buffer.put(endHeader.getBytes());
// Do not populate file if there are no vertices
if (mesh.getVertices().isEmpty()) {
return buffer.array();
}
// Write vertices
TIntIntHashMap refToVertId = new TIntIntHashMap( mesh.getVertices().size() );
Vertex3Pool vp = mesh.getVertex3Pool();
int vertId = 0;
for( Vertex3 v : mesh.getVertices() ) {
buffer.putFloat((float) v.getX());
buffer.putFloat((float) v.getY());
buffer.putFloat((float) v.getZ());
buffer.putFloat((float) v.getNX());
buffer.putFloat((float) v.getNY());
buffer.putFloat((float) v.getNZ());
buffer.putFloat((float) v.getU());
buffer.putFloat((float) v.getV());
buffer.putFloat((float) v.getW());
refToVertId.put( vp.getId(v), vertId);
++vertId;
}
// Write triangles
for( Triangle t : mesh.getTriangles() ) {
buffer.put((byte) 3);
buffer.putInt(refToVertId.get(t.getVertex(0).getInternalPoolIndex()));
buffer.putInt(refToVertId.get(t.getVertex(1).getInternalPoolIndex()));
buffer.putInt(refToVertId.get(t.getVertex(2).getInternalPoolIndex()));
}
return buffer.array();
}
示例11: writeAscii
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
@Override
public byte[] writeAscii(Mesh mesh) throws IOException {
final int vertexBytes = 3 * 4 + 3 * 4 + 3 * 4;
final int triangleBytes = 3 * 4 + 1;
final String header = "ply\nformat ascii 1.0\ncomment This binary PLY mesh was created with imagej-mesh.\n";
final String vertexHeader = "element vertex " + mesh.getVertices().size() + "\nproperty float x\nproperty float y\nproperty float z\nproperty float nx\nproperty float ny\nproperty float nz\nproperty float r\n property float g\n property float b\n";
final String triangleHeader = "element face " + mesh.getTriangles().size() + "\nproperty list uchar int vertex_index\n";
final String endHeader = "end_header\n";
ByteArrayOutputStream os=new ByteArrayOutputStream();
Writer writer = new OutputStreamWriter(os, "UTF-8");
writer.write(header+vertexHeader+triangleHeader+endHeader);
writer.flush();
// Do not populate file if there are no vertices
if (mesh.getVertices().isEmpty()) {
return os.toByteArray();
}
// Write vertices
TIntIntHashMap refToVertId = new TIntIntHashMap( mesh.getVertices().size() );
Vertex3Pool vp = mesh.getVertex3Pool();
int vertId = 0;
for( Vertex3 v : mesh.getVertices() ) {
writer.write(Float.toString((float) v.getX()));
writer.write(' ');
writer.write(Float.toString((float) v.getY()));
writer.write(' ');
writer.write(Float.toString((float) v.getZ()));
writer.write(' ');
writer.write(Float.toString((float) v.getNX()));
writer.write(' ');
writer.write(Float.toString((float) v.getNY()));
writer.write(' ');
writer.write(Float.toString((float) v.getNZ()));
writer.write(' ');
writer.write(Float.toString((float) v.getU()));
writer.write(' ');
writer.write(Float.toString((float) v.getV()));
writer.write(' ');
writer.write(Float.toString((float) v.getW()));
writer.write('\n');
refToVertId.put( vp.getId(v), vertId);
++vertId;
}
// Write triangles
for( Triangle t : mesh.getTriangles() ) {
writer.write("3 ");
writer.write(Integer.toString(refToVertId.get(t.getVertex(0).getInternalPoolIndex())));
writer.write(' ');
writer.write(Integer.toString(refToVertId.get(t.getVertex(1).getInternalPoolIndex())));
writer.write(' ');
writer.write(Integer.toString(refToVertId.get(t.getVertex(2).getInternalPoolIndex())));
writer.write('\n');
}
writer.flush();
return os.toByteArray();
}
示例12: setup
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
@Override
public void setup(final int[] keys, final float fillFactor, int oneFailOutOf) {
super.setup( keys, fillFactor, oneFailOutOf );
m_map = new TIntIntHashMap( keys.length, fillFactor );
for (int key : keys) m_map.put( key + (key % oneFailOutOf == 0 ? 1 : 0), key );
}
示例13: initialize
import gnu.trove.map.hash.TIntIntHashMap; //导入方法依赖的package包/类
public void initialize () {
if (random == null) {
random = new Randoms();
}
gammaSum = gamma * numStates;
stateTopicCounts = new int[numStates][numTopics];
stateTopicTotals = new int[numStates];
stateStateTransitions = new int[numStates][numStates];
stateTransitionTotals = new int[numStates];
pi = 1000.0;
sumPi = numStates * pi;
int maxTokens = 0;
int totalTokens = 0;
numSequences = 0;
int sequenceID;
int currentSequenceID = -1;
// The code to cache topic distributions
// takes an int-int hashmap as a mask to only update
// the distributions for topics that have actually changed.
// Here we create a dummy count hash that has all the topics.
TIntIntHashMap allTopicsDummy = new TIntIntHashMap();
for (int topic = 0; topic < numTopics; topic++) {
allTopicsDummy.put(topic, 1);
}
for (int state=0; state < numStates; state++) {
recacheStateTopicDistribution(state, allTopicsDummy);
}
for (int doc = 0; doc < numDocs; doc++) {
sampleState(doc, random, true);
}
}