本文整理匯總了Java中gnu.trove.map.hash.TLongObjectHashMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java TLongObjectHashMap.put方法的具體用法?Java TLongObjectHashMap.put怎麽用?Java TLongObjectHashMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.map.hash.TLongObjectHashMap
的用法示例。
在下文中一共展示了TLongObjectHashMap.put方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadLong2TXTGZMap
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
public static TLongObjectHashMap loadLong2TXTGZMap(String mapFile, boolean reverse) throws IOException {
long time = System.currentTimeMillis();
TLongObjectHashMap idMap = new TLongObjectHashMap();
BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(mapFile))));
String line;
String[] parts;
while ((line = br.readLine()) != null) {
parts = line.split(SEP);
if (!reverse) {
idMap.put(Long.parseLong(parts[0]), parts[1]);
} else {
idMap.put(Long.parseLong(parts[1]), parts[0]);
}
}
logger.info(((System.currentTimeMillis() - time) / 1000d) + "s");
return idMap;
}
示例2: load
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
/**
*
* @see org.jmangos.commons.dataholder.DataLoadService#load()
*/
@Override
public TLongObjectHashMap<ItemPrototype> load() {
Long eTime = System.currentTimeMillis();
final TLongObjectHashMap<ItemPrototype> map = new TLongObjectHashMap<ItemPrototype>();
final List<ItemPrototype> itemPrototypeList =
this.itemPrototypeService.readItemPrototypes();
// Fill map
for (final ItemPrototype item : itemPrototypeList) {
map.put(item.getEntry(), item);
}
eTime = System.currentTimeMillis() - eTime;
ItemStorages.logger.info(String.format("Loaded [%d] ItemPrototypes under %d ms",
map.size(), eTime));
this.itemPrototypes = map;
return this.itemPrototypes;
}
示例3: manualSnchronizedTLongObjectHashMapMapCopy
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
@Benchmark
public TLongObjectHashMap manualSnchronizedTLongObjectHashMapMapCopy(Context context) {
TLongObjectHashMap<Object> map = new TLongObjectHashMap<>();
synchronized (map) {
//Populate the map the first time
for (int i = 0; i < context.testValues.length; i++)
map.put(context.testKeys[i], context.testValues[i]);
//Copy!
TLongObjectHashMap<Object> copy = new TLongObjectHashMap<>(map);
return copy;
}
}
示例4: initialize
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
public static synchronized void initialize(EntityManager em) {
TLongObjectHashMap<Currency> currencies = new TLongObjectHashMap<Currency>();
Query<Currency> q = em.createQuery(Currency.class);
Cursor c = q.execute();
try {
while (c.moveToNext()) {
Currency currency = EntityManager.loadFromCursor(c, Currency.class);
currencies.put(currency.id, currency);
}
} finally {
c.close();
}
CURRENCIES.putAll(currencies);
}
示例5: aggregate
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
public boolean aggregate() {
if (size == 0) return false;
boolean aggregated = false;
//HashMap<Long, MatrixEntry> table = new HashMap<Long, MatrixEntry>();
TLongObjectHashMap<Entry> table = new TLongObjectHashMap<Entry>();
for (int i = 0; i < size; ++i) {
int id = x[i];
Entry item = table.get(id);
if (item != null) {
item.value += va[i];
aggregated = true;
} else
table.put(id, new Entry(id, va[i]));
}
if (!aggregated) return false;
int p = 0;
for (Entry e : table.valueCollection()) {
if (e.value != 0) {
x[p] = e.x;
va[p] = e.value;
++p;
}
}
size = p;
return true;
}
示例6: index
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
private void index(long key, int val, TLongObjectHashMap<TIntArrayList> map) {
TIntArrayList list = map.get(key);
if (list == null) {
list = new TIntArrayList(Constants.DEFAULT_CAPACITY, -1);
map.put(key, list);
}
if (list.contains(val))
return;
list.add(val);
}
示例7: testObjectMapNull
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
@Test
public void testObjectMapNull() {
TLongObjectHashMap<AllocationMethod> map = new TLongObjectHashMap<>();
Assert.assertNull(map.get(4));
map.put(203040L, AllocationMethod.CAUSAL);
Assert.assertEquals(AllocationMethod.CAUSAL, map.get(203040L));
}
示例8: index
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
void index(long key, int val, TLongObjectHashMap<TIntArrayList> map) {
TIntArrayList list = map.get(key);
if (list == null) {
list = new TIntArrayList(Constants.DEFAULT_CAPACITY, -1);
map.put(key, list);
}
if (list.contains(val))
return;
list.add(val);
}
示例9: testCreateConnections
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
@Test
public void testCreateConnections() {
ConnectionsBuilder connectionsBuilder = new ConnectionsBuilder();
long segmentFromId = 258306367;
long segmentToId = 258306365;
long segmentTo2Id = 143558685;
long nodeId = 269468749;
TLongObjectHashMap<List<Relation>> wayRelations = new TLongObjectHashMap<>();
RelationMember memberFrom = new RelationMember(segmentFromId, EntityType.Way, "from");
RelationMember memberNode = new RelationMember(nodeId, EntityType.Node, "via");
RelationMember memberTo = new RelationMember(segmentToId, EntityType.Way, "to");
List<RelationMember> members = new ArrayList<>();
members.add(memberFrom);
members.add(memberNode);
members.add(memberTo);
Relation rel = new Relation(new CommonEntityData(1, 1, new Date(), new OsmUser(1, "user"), 1), members);
rel.getTags().add(new Tag("type", "restriction"));
rel.getTags().add(new Tag("restriction", "only_right_turn"));
List<Relation> relations = new ArrayList<>();
relations.add(rel);
wayRelations.put(258306367, relations);
Set<Access> defaultAccesses = new HashSet<>();
defaultAccesses.add(Access.PRIVATE_CAR);
IWaySegment segmentFrom = new WaySegment();
segmentFrom.setId(segmentFromId);
segmentFrom.setStartNodeId(nodeId);
IWaySegment segmentTo = new WaySegment();
segmentTo.setId(segmentToId);
segmentTo.setEndNodeId(nodeId);
IWaySegment segmentTo2 = new WaySegment();
segmentTo2.setId(segmentTo2Id);
segmentTo2.setEndNodeId(nodeId);
List<IWaySegment> segmentsTo = new ArrayList<>();
segmentsTo.add(segmentTo);
segmentsTo.add(segmentTo2);
connectionsBuilder.createConnections(segmentFrom, segmentsTo, nodeId, defaultAccesses, wayRelations);
Assert.assertEquals(1, segmentFrom.getStartNodeCons().size());
}
示例10: TsvChain
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
public TsvChain(@NonNull DateTime initTs, @NonNull TimeSeriesValue initTsv) {
final TLongObjectHashMap<TimeSeriesValue> tail = new TLongObjectHashMap<>();
tail.put(initTs.getMillis(), initTsv);
tailRefForAccess = new SoftReference<>(tail);
tailRefForUpdate = new WeakReference<>(tail);
}
示例11: getFeatureIterator
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
public void getFeatureIterator(final IScope scope, final boolean returnIt) {
final TLongObjectHashMap<GamaShape> nodesPt = new TLongObjectHashMap<GamaShape>();
final List<Node> nodes = new ArrayList<Node>();
final List<Way> ways = new ArrayList<Way>();
final TLongHashSet intersectionNodes = new TLongHashSet();
final TLongHashSet usedNodes = new TLongHashSet();
final Sink sinkImplementation = new Sink() {
@Override
public void process(final EntityContainer entityContainer) {
final Entity entity = entityContainer.getEntity();
final boolean toFilter = filteringOptions != null && !filteringOptions.isEmpty();
if (entity instanceof Bound) {
final Bound bound = (Bound) entity;
final Envelope3D env =
new Envelope3D(bound.getLeft(), bound.getRight(), bound.getBottom(), bound.getTop(), 0, 0);
computeProjection(scope, env);
} else if (returnIt) {
if (entity instanceof Node) {
final Node node = (Node) entity;
nodes.add(node);
final Geometry g = gis == null
? new GamaPoint(node.getLongitude(), node.getLatitude()).getInnerGeometry()
: gis.transform(
new GamaPoint(node.getLongitude(), node.getLatitude()).getInnerGeometry());
nodesPt.put(node.getId(), new GamaShape(g));
} else if (entity instanceof Way) {
if (toFilter) {
boolean keepObject = false;
for (final String keyN : filteringOptions.getKeys()) {
final GamaList valsPoss = filteringOptions.get(keyN);
for (final Tag tagN : ((Way) entity).getTags()) {
if (keyN.equals(tagN.getKey())) {
if (valsPoss == null || valsPoss.isEmpty()
|| valsPoss.contains(tagN.getValue())) {
keepObject = true;
break;
}
}
}
}
if (!keepObject) { return; }
}
registerHighway((Way) entity, usedNodes, intersectionNodes);
ways.add((Way) entity);
}
}
}
@Override
public void release() {}
@Override
public void complete() {}
@Override
public void initialize(final Map<String, Object> arg0) {}
};
readFile(scope, sinkImplementation, getFile(scope));
if (returnIt) {
setBuffer(buildGeometries(nodes, ways, intersectionNodes, nodesPt));
}
}
示例12: initialize
import gnu.trove.map.hash.TLongObjectHashMap; //導入方法依賴的package包/類
private void initialize(@Nonnull T update) {
TLongObjectHashMap<Object> values = new TLongObjectHashMap<>();
values.put(key, update);
CURRENT_VALUES.set(values);
}