本文整理匯總了Java中gnu.trove.map.hash.TIntObjectHashMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntObjectHashMap.put方法的具體用法?Java TIntObjectHashMap.put怎麽用?Java TIntObjectHashMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.map.hash.TIntObjectHashMap
的用法示例。
在下文中一共展示了TIntObjectHashMap.put方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: register
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public void register(Item item, int meta, ModelResourceLocation location)
{
TIntObjectHashMap<ModelResourceLocation> locs = locations.get(item);
TIntObjectHashMap<IBakedModel> mods = models.get(item);
if (locs == null)
{
locs = new TIntObjectHashMap<ModelResourceLocation>();
locations.put(item, locs);
}
if (mods == null)
{
mods = new TIntObjectHashMap<IBakedModel>();
models.put(item, mods);
}
locs.put(meta, location);
mods.put(meta, getModelManager().getModel(location));
}
示例2: DynamicGrid
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public DynamicGrid(T defaultElement, T[][] data){
this(defaultElement);
for(int x = 0; x < data.length; ++x){
T[] arr = data[x];
TIntObjectHashMap<T> map = new TIntObjectHashMap<>();
for(int y = 0; y < arr.length; ++y){
T element = arr[y];
if(element != null){
map.put(y, element);
}
}
map.compact();
grid.put(x, map);
}
grid.compact();
}
示例3: loadFileIndex
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public static void loadFileIndex(String file, TIntObjectHashMap<String> id_value){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
id_value.put(Integer.parseInt(vals[0]), vals[1]+":"+vals[2]);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例4: loadIndex
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public static void loadIndex(String file, TIntObjectHashMap<String> id_value){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
id_value.put(Integer.parseInt(vals[0]), vals[1]);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例5:
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
/**
* <p>
* Invert an index of quantised features. The inversion process swaps keys
* and feature {@link QuantisedLocalFeature#id}s around so that the inverted
* index is a hash of ids to {@link QuantisedLocalFeature}s with the
* {@link Object#hashCode()} of the key stored in the
* {@link QuantisedLocalFeature#id} field.
* </p>
* <p>
* The original index is not affected by the inversion operation.
* </p>
*
* @param <T>
* the type of local feature.
* @param <K>
* the type of key.
* @param index
* the index to invert.
* @return an inverted-index data structure.
*/
public static <K extends ReadWriteable, T extends QuantisedLocalFeature<?>>
TIntObjectHashMap<TIntObjectHashMap<List<T>>>
invert(LocalFeatureListIndex<K, T> index)
{
final TIntObjectHashMap<TIntObjectHashMap<List<T>>> invertedIndex = new TIntObjectHashMap<TIntObjectHashMap<List<T>>>();
for (final Entry<K, LocalFeatureList<T>> e : index.entrySet()) {
final K docid = e.getKey();
for (final T t : e.getValue()) {
final int termid = t.id;
if (!invertedIndex.containsKey(termid))
invertedIndex.put(termid, new TIntObjectHashMap<List<T>>());
final TIntObjectHashMap<List<T>> postings = invertedIndex.get(termid);
if (!postings.containsKey(docid.hashCode()))
postings.put(docid.hashCode(), new ArrayList<T>());
postings.get(docid.hashCode()).add(t);
}
}
return invertedIndex;
}
示例6: testEquals
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public void testEquals() {
int element_count = 20;
int[] keys = new int[element_count];
String[] vals = new String[element_count];
TIntObjectMap<String> raw_map =
new TIntObjectHashMap<String>(element_count, 0.5f, Integer.MIN_VALUE);
for (int i = 0; i < element_count; i++) {
keys[i] = i + 1;
vals[i] = Integer.toString(i + 1);
raw_map.put(keys[i], vals[i]);
}
Map<Integer, String> map = TDecorators.wrap(raw_map);
assertEquals(element_count, map.size());
TIntObjectHashMap<String> raw_fully_specified =
new TIntObjectHashMap<String>(20, 0.75f, Integer.MIN_VALUE);
for (int i = 0; i < element_count; i++) {
raw_fully_specified.put(keys[i], vals[i]);
}
Map<Integer, String> fully_specified = TDecorators.wrap(raw_fully_specified);
assertEquals(map, fully_specified);
assertFalse("shouldn't equal random object", map.equals(new Object()));
assertSame(raw_map, ((TIntObjectMapDecorator) map).getMap());
}
示例7: generateSectionsMap
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
private static TIntObjectHashMap<Map<String, Tag<?>>> generateSectionsMap(Map<String, Tag<?>> levelData) {
ListTag<CompoundTag> sectionsList = (ListTag<CompoundTag>) levelData.get("Sections");
TIntObjectHashMap<Map<String, Tag<?>>> map = new TIntObjectHashMap<>();
for (CompoundTag tag : sectionsList.getValue()) {
int y = ((ByteTag) tag.getValue().get("Y")).getValue();
map.put(y, tag.getValue());
}
return map;
}
示例8: loadRelatedURIs
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public static void loadRelatedURIs(String file, TIntObjectHashMap<TIntArrayList> related_uri,
TObjectIntHashMap<String> uri_id){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
TIntArrayList tmp = null;
while((line=br.readLine()) != null){
tmp = new TIntArrayList();
String[] vals = line.split(",");
for(int i = 1; i < vals.length; i++){
if(!vals[i].contentEquals("null") && uri_id.containsKey(vals[i]))
tmp.add(uri_id.get(vals[i]));
}
if(uri_id.containsKey(vals[0]))
related_uri.put(uri_id.get(vals[0]), tmp);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例9: read
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public TIntObjectHashMap<ItemTree> read(long n){
TIntObjectHashMap<ItemTree> res = new TIntObjectHashMap<ItemTree>();
long count = 0;
for(String key : file_index.keySet()){
if(count < n){
ItemTree tmp = read(key);
res.put(tmp.getItemId(), tmp);
count++;
}
else
break;
}
return res;
}
示例10: splitRatings
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
private void splitRatings(TIntObjectHashMap<TIntFloatHashMap> map1,
TIntObjectHashMap<TIntFloatHashMap> map2, float ratio,
int minRatings) {
TIntSet users = map1.keySet();
TIntIterator it = users.iterator();
int u, i;
TIntArrayList candidate;
Set<Integer> usersToRemove = new HashSet();
int splits = 0;
while (it.hasNext()) {
u = it.next();
TIntSet tmp = map1.get(u).keySet();
candidate = new TIntArrayList();
candidate.addAll(tmp);
int n = (int) (ratio * candidate.size());
if (n > minRatings) {
map2.put(u, new TIntFloatHashMap());
splits++;
TIntSet validItems = chooseRndItems(candidate, n);
TIntIterator itt = validItems.iterator();
// System.out.println(this.trainRatings.get(u).size() +" - "+
// this.validationRatings.get(u).size());
while (itt.hasNext()) {
i = itt.next();
map2.get(u).put(i, map1.get(u).get(i));
map1.get(u).remove(i);
}
} else
usersToRemove.add(u);
}
for (int us : usersToRemove)
map1.remove(us);
System.out.println("n.users map1 " + map1.keys().length
+ " n.users map2 " + map2.keys().length + " n.splits "
+ splits);
}
示例11: initWorldPixelWayPoint
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
private TIntObjectHashMap<Point> initWorldPixelWayPoint(final TourData tourData,
final Set<TourWayPoint> wayPoints,
final MP mp,
final String projectionId,
final int mapZoomLevel) {
// world pixels are not yet cached, create them now
final TIntObjectHashMap<Point> allWayPointWorldPixel = new TIntObjectHashMap<Point>();
for (final TourWayPoint twp : wayPoints) {
// convert lat/long into world pixels which depends on the map projection
final GeoPosition geoPosition = new GeoPosition(twp.getLatitude(), twp.getLongitude());
allWayPointWorldPixel.put(twp.hashCode(), mp.geoToPixel(geoPosition, mapZoomLevel));
}
tourData.setWorldPixelForWayPoints(allWayPointWorldPixel, mapZoomLevel, projectionId);
return allWayPointWorldPixel;
}
示例12: analyseImage
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
@Override
public void analyseImage(FImage image) {
final int height = image.getHeight();
final int width = image.getWidth();
this.radmap = new TIntObjectHashMap<TIntObjectHashMap<TIntFloatHashMap>>();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (image.pixels[y][x] == 1)
{
for (int rad = 0; rad < nRadius; rad++) {
final int actualrad = (rad * this.radIncr) + this.minRad;
final float radiusWeight = 1f / this.nDegree;
// if(actualrad == 0){
// throw new
// RuntimeException("The weight should never be 0");
// }
for (int ang = 0; ang < nDegree; ang++) {
final int x0 = round(x + this.cosanglemap[rad][ang]);
final int y0 = round(y + this.sinanglemap[rad][ang]);
TIntObjectHashMap<TIntFloatHashMap> xMap = this.radmap.get(actualrad);
if (xMap == null) {
this.radmap.put(actualrad, xMap = new TIntObjectHashMap<TIntFloatHashMap>());
}
TIntFloatHashMap yMap = xMap.get(x0);
if (yMap == null) {
xMap.put(x0, yMap = new TIntFloatHashMap());
}
yMap.adjustOrPutValue(y0, radiusWeight, radiusWeight);
// if(x0 == 37 && y0 == 22 && actualrad == 1){
// logger.debug("This should not be !");
// logger.debug(String.format("Pixel = %d,%d",
// x,y));
// logger.debug(String.format("x=%d,y=%d,r=%d,v=%2.5f",x0
// ,y0 ,actualrad , newValue ));
// }
// if(x0 > 22 && x0 < 27 && y0 > 22 && y0 < 27 &&
// actualrad > 10 && actualrad < 14){
// logger.debug("This should be correct!");
// logger.debug(String.format("x=%d,y=%d,r=%d,v=%2.5f",x0
// ,y0 ,actualrad , newValue ));
// }
// if(Float.isInfinite(newValue)){
// throw new
// RuntimeException("The value held should never be infinity");
// }
// logger.debug(String.format("x=%d,y=%d,r=%d,v=%2.5f\n",x0
// ,y0 ,actualrad , newValue ));
// maxWeight = Math.max(newValue, maxWeight);
}
}
}
}
}
logger.debug("Done analysing the image!");
}
示例13: loadTIntMapArrayString
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public static void loadTIntMapArrayString(String file, TIntObjectHashMap<ArrayList<String>> map){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
String[] vals1 = vals[1].split(",");
ArrayList<String> tmp = new ArrayList<String>();
for(String s : vals1)
tmp.add(s);
map.put(Integer.parseInt(vals[0]), tmp);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}
示例14: loadTIntMapTIntHashSet
import gnu.trove.map.hash.TIntObjectHashMap; //導入方法依賴的package包/類
public static void loadTIntMapTIntHashSet(String file, TIntObjectHashMap<TIntHashSet> map){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
while((line=br.readLine()) != null){
String[] vals = line.split("\t");
String[] vals1 = vals[1].split(",");
TIntHashSet tmp = new TIntHashSet();
for(String s : vals1)
tmp.add(Integer.parseInt(s));
map.put(Integer.parseInt(vals[0]), tmp);
}
br.close();
}
catch(Exception e){
e.printStackTrace();
}
}