本文整理匯總了Java中it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java Int2ObjectOpenHashMap.put方法的具體用法?Java Int2ObjectOpenHashMap.put怎麽用?Java Int2ObjectOpenHashMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
的用法示例。
在下文中一共展示了Int2ObjectOpenHashMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTaskMatrixClocks
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Get task clocks for all matrices from Master
* @return task clocks for all matrices from Master
* @throws ServiceException
*/
public Int2ObjectOpenHashMap<Int2IntOpenHashMap> getTaskMatrixClocks() throws ServiceException {
GetTaskMatrixClockResponse response = masterProxy.getTaskMatrixClocks(null,
GetTaskMatrixClockRequest.newBuilder().build());
Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskIdToMatrixClocksMap = new Int2ObjectOpenHashMap<>(response.getTaskMatrixClocksCount());
List<TaskMatrixClock> taskMatrixClocks = response.getTaskMatrixClocksList();
int size = taskMatrixClocks.size();
int matrixNum;
for(int i = 0; i < size; i++) {
Int2IntOpenHashMap matrixIdToClockMap = new Int2IntOpenHashMap(taskMatrixClocks.get(i).getMatrixClocksCount());
taskIdToMatrixClocksMap.put(taskMatrixClocks.get(i).getTaskId().getTaskIndex(), matrixIdToClockMap);
List<MatrixClock> matrixClocks = taskMatrixClocks.get(i).getMatrixClocksList();
matrixNum = matrixClocks.size();
for(int j = 0; j < matrixNum; j++) {
matrixIdToClockMap.put(matrixClocks.get(j).getMatrixId(), matrixClocks.get(j).getClock());
}
}
return taskIdToMatrixClocksMap;
}
示例2: output
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
private void output() throws CouldNotReceiveResultException, ColumnNameMismatchException {
// Read the discovered INDs from the attributes
Int2ObjectOpenHashMap<IntList> dep2ref = new Int2ObjectOpenHashMap<IntList>(this.numColumns);
for (Attribute spiderAttribute : this.attributeId2attributeObject.values())
if (!spiderAttribute.getReferenced().isEmpty())
dep2ref.put(spiderAttribute.getAttributeId(), new IntArrayList(spiderAttribute.getReferenced()));
// Write the result to the resultReceiver
for (int dep : dep2ref.keySet()) {
String depTableName = this.getTableNameFor(dep, this.tableColumnStartIndexes);
String depColumnName = this.columnNames.get(dep);
for (int ref : dep2ref.get(dep)) {
String refTableName = this.getTableNameFor(ref, this.tableColumnStartIndexes);
String refColumnName = this.columnNames.get(ref);
this.resultReceiver.receiveResult(new InclusionDependency(new ColumnPermutation(new ColumnIdentifier(depTableName, depColumnName)), new ColumnPermutation(new ColumnIdentifier(refTableName, refColumnName))));
this.numUnaryINDs++;
}
}
}
示例3: generalize
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
public void generalize() {
int maxLevel = this.numAttributes;
// Build an index level->nodes for the top-down, level-wise traversal
Int2ObjectOpenHashMap<ArrayList<ElementLhsPair>> level2elements = new Int2ObjectOpenHashMap<>(maxLevel);
for (int level = 0; level < maxLevel; level++)
level2elements.put(level, new ArrayList<ElementLhsPair>());
this.addToIndex(level2elements, 0, new OpenBitSet(this.numAttributes));
// Traverse the levels top-down and add all direct generalizations
for (int level = maxLevel - 1; level >= 0; level--) {
for (ElementLhsPair pair : level2elements.get(level)) {
// Remove isFDs, because we will mark valid FDs later on
pair.element.removeAllFds();
// Generate and add generalizations
for (int lhsAttr = pair.lhs.nextSetBit(0); lhsAttr >= 0; lhsAttr = pair.lhs.nextSetBit(lhsAttr + 1)) {
pair.lhs.clear(lhsAttr);
FDTreeElement generalization = this.addGeneralization(pair.lhs, pair.element.getRhsAttributes());
if (generalization != null)
level2elements.get(level - 1).add(new ElementLhsPair(generalization, pair.lhs.clone()));
pair.lhs.set(lhsAttr);
}
}
}
}
示例4: calculateLayerArrays
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
protected void calculateLayerArrays() {
Int2ObjectOpenHashMap<char[]> colorLayerMap = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < validBlockIds.length; i++) {
int color = validColors[i];
int combined = validBlockIds[i];
if (hasAlpha(color)) {
for (int j = 0; j < validBlockIds.length; j++) {
int colorOther = validColors[j];
if (!hasAlpha(colorOther)) {
int combinedOther = validBlockIds[j];
int combinedColor = combineTransparency(color, colorOther);
colorLayerMap.put(combinedColor, new char[]{(char) combined, (char) combinedOther});
}
}
}
}
this.validLayerColors = new int[colorLayerMap.size()];
this.validLayerBlocks = new char[colorLayerMap.size()][];
int index = 0;
for (Int2ObjectMap.Entry<char[]> entry : colorLayerMap.int2ObjectEntrySet()) {
validLayerColors[index] = entry.getIntKey();
validLayerBlocks[index++] = entry.getValue();
}
}
示例5: load
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* List of lines are generated from a given file. then this list is used to generate a NodeNamerImpl
*
* @param file
* @return INodeNamer
* @throws IOException
*/
public static INodeNamer load(final File file) throws IOException {
final int numNodes = countLines(file, Encoding.DEFAULT_CHARSET_NAME);
final Int2ObjectOpenHashMap<String> id2Label = new Int2ObjectOpenHashMap<String>(numNodes);
final Object2IntOpenHashMap<String> label2Id = new Object2IntOpenHashMap<String>(numNodes);
final LineIterator it = FileUtils.lineIterator(file, Encoding.DEFAULT_CHARSET_NAME);
try {
int curId = 0;
while(it.hasNext()) {
final String nodeName = it.next();
id2Label.put(curId, nodeName);
label2Id.put(nodeName, curId);
curId++;
}
return new NodeNamerImpl(id2Label, label2Id);
} finally {
it.close();
}
}
示例6: readFieldsForPartition
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
@Override
public void readFieldsForPartition(DataInput in,
int partitionId) throws IOException {
int size = in.readInt();
Int2ObjectOpenHashMap<DataInputOutput> partitionMap =
new Int2ObjectOpenHashMap<DataInputOutput>(size);
while (size-- > 0) {
int vertexId = in.readInt();
DataInputOutput dataInputOutput = config.createMessagesInputOutput();
dataInputOutput.readFields(in);
partitionMap.put(vertexId, dataInputOutput);
}
synchronized (map) {
map.put(partitionId, partitionMap);
}
}
示例7: getBlocks
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
public Map<Integer, Integer> getBlocks() {
Int2ObjectOpenHashMap<Integer> map = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < blocks.length; i++) {
if (blocks[i] != 0) {
map.put(i, (Integer) blocks[i]);
}
}
return map;
}
示例8: getPercents
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
public Map<Integer, Double> getPercents() {
Map<Integer, Integer> map = getBlocks();
int count = getSize();
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<Double>();
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
int id = entry.getKey();
int changes = entry.getValue();
double percent = ((changes * 1000l) / count) / 10d;
newMap.put(id, (Double) percent);
}
return newMap;
}
示例9: merge
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Execute the cluster merge
*
* @param size size of data set
* @param mat Matrix paradigm
* @param prots the prototypes of merges between clusters
* @param builder Result builder
* @param clusters the current clustering
* @param dq the range query
* @param bestd the distances to the nearest neighboring cluster
* @param besti the nearest neighboring cluster
* @param x first cluster to merge, with x > y
* @param y second cluster to merge, with y < x
*/
protected void merge(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<O> dq, double[] bestd, int[] besti, int x, int y) {
final DBIDArrayIter ix = mat.ix.seek(x), iy = mat.iy.seek(y);
final double[] distances = mat.matrix;
int offset = MatrixParadigm.triangleSize(x) + y;
assert (y < x);
if(LOG.isDebuggingFine()) {
LOG.debugFine("Merging: " + DBIDUtil.toString(ix) + " -> " + DBIDUtil.toString(iy) + " " + distances[offset]);
}
ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y);
// Keep y
if(cy == null) {
cy = DBIDUtil.newHashSet();
cy.add(iy);
}
if(cx == null) {
cy.add(ix);
}
else {
cy.addDBIDs(cx);
clusters.remove(x);
}
clusters.put(y, cy);
// parent of x is set to y
builder.add(ix, distances[offset], iy, prots.seek(offset));
// Deactivate x in cache:
besti[x] = -1;
updateMatrices(size, mat, prots, builder, clusters, dq, bestd, besti, x, y);
if(besti[y] == x) {
findBest(size, distances, bestd, besti, y);
}
}
示例10: merge
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Merges two clusters given by x, y, their points with smallest IDs, and y to
* keep
*
* @param size number of ids in the data set
* @param mat distance matrix
* @param prots calculated prototypes
* @param builder Result builder
* @param clusters the clusters
* @param dq distance query of the data set
* @param x first cluster to merge
* @param y second cluster to merge
*/
protected static void merge(int size, MatrixParadigm mat, DBIDArrayMIter prots, PointerHierarchyRepresentationBuilder builder, Int2ObjectOpenHashMap<ModifiableDBIDs> clusters, DistanceQuery<?> dq, int x, int y) {
assert (y < x);
final DBIDArrayIter ix = mat.ix.seek(x), iy = mat.iy.seek(y);
final double[] distances = mat.matrix;
int offset = MatrixParadigm.triangleSize(x) + y;
if(LOG.isDebuggingFine()) {
LOG.debugFine("Merging: " + DBIDUtil.toString(ix) + " -> " + DBIDUtil.toString(iy) + " " + distances[offset]);
}
ModifiableDBIDs cx = clusters.get(x), cy = clusters.get(y);
// Keep y
if(cy == null) {
cy = DBIDUtil.newHashSet();
cy.add(iy);
}
if(cx == null) {
cy.add(ix);
}
else {
cy.addDBIDs(cx);
clusters.remove(x);
}
clusters.put(y, cy);
// parent of x is set to y
builder.add(ix, distances[offset], iy, prots.seek(offset));
updateMatrices(size, mat, prots, builder, clusters, dq, y);
}
示例11: test
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
@Override
public int test() {
final Int2ObjectOpenHashMap<Integer> m_map = new Int2ObjectOpenHashMap<>( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], null );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], null );
return m_map.size();
}
示例12: switchToMapMode
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Helper method to switch the storage from array mode to map mode.
*
* @param initialPriorityQueueSize Initial size of priority queue
*/
@SuppressWarnings("unchecked")
private void switchToMapMode(int initialPriorityQueueSize) {
_storageMode = StorageMode.MAP_STORAGE;
_resultMap = new Int2ObjectOpenHashMap(_resultArray.length);
_priorityQueue = new IntObjectIndexedPriorityQueue(initialPriorityQueueSize, _minHeap);
for (int id = 0; id < _resultArray.length; id++) {
_resultMap.put(id, _resultArray[id]);
_priorityQueue.put(id, (Comparable) _resultArray[id]);
}
_resultArray = null;
}
示例13: getDataInputOutput
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Get the DataInputOutput for a vertex id, creating if necessary.
*
* @param partitionMap Partition map to look in
* @param vertexId Id of the vertex
* @return DataInputOutput for this vertex id (created if necessary)
*/
private DataInputOutput getDataInputOutput(
Int2ObjectOpenHashMap<DataInputOutput> partitionMap,
int vertexId) {
DataInputOutput dataInputOutput = partitionMap.get(vertexId);
if (dataInputOutput == null) {
dataInputOutput = config.createMessagesInputOutput();
partitionMap.put(vertexId, dataInputOutput);
}
return dataInputOutput;
}
示例14: getNeedMergeRows
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
/**
* Get the rows that need to be merged
*
* @return Int2ObjectOpenHashMap<List<ServerRow>> need merge rows and the splits of them
*/
public Int2ObjectOpenHashMap<List<ServerRow>> getNeedMergeRows() {
Int2ObjectOpenHashMap<List<ServerRow>> needMergeRowsSplit =
new Int2ObjectOpenHashMap<List<ServerRow>>();
ObjectIterator<Future<List<ServerRow>>> iter = rowsSplitFutures.iterator();
while (iter.hasNext()) {
Future<List<ServerRow>> futureResult = iter.next();
// Check if the result of the sub-request is received
if (futureResult.isDone()) {
// Update received result number
updateReceivedResponse();
// Get row splits received
List<ServerRow> rowSplits;
try {
rowSplits = futureResult.get();
} catch (InterruptedException | ExecutionException e) {
LOG.warn("get result from future failed.", e);
continue;
}
int num = rowSplits.size();
for (int j = 0; j < num; j++) {
int rowIndex = rowSplits.get(j).getRowId();
// Put the row split to the cache(row index to row splits map)
List<ServerRow> cachedRowSplits = rowsSplitCache.get(rowIndex);
if (cachedRowSplits == null) {
cachedRowSplits = new ArrayList<ServerRow>();
rowsSplitCache.put(rowIndex, cachedRowSplits);
}
cachedRowSplits.add(rowSplits.get(j));
// If all splits of the row are received, means this row can be merged
if (getRowPartSize(rowIndex) == cachedRowSplits.size()) {
needMergeRowsSplit.put(rowIndex, rowsSplitCache.remove(rowIndex));
}
}
iter.remove();
}
}
return needMergeRowsSplit;
}
示例15: getLayer
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; //導入方法依賴的package包/類
@Override
public final MappedByteBuffer getLayer(final int layerIndex)
throws OutOfMemoryError {
if(layerIndex == 0) {
return inputBuff;
}
Int2ObjectOpenHashMap<MappedByteBuffer> layersCache = thrLocLayersCache.get();
if(layersCache == null) {
layersCache = new Int2ObjectOpenHashMap<>(layersCacheCountLimit - 1);
thrLocLayersCache.set(layersCache);
}
// check if layer exists
MappedByteBuffer layer = layersCache.get(layerIndex - 1);
if(layer == null) {
// check if it's necessary to free the space first
int layersCountToFree = layersCacheCountLimit - layersCache.size() + 1;
final int layerSize = inputBuff.capacity();
if(layersCountToFree > 0) {
for(final int i : layersCache.keySet()) {
layer = layersCache.remove(i);
if(layer != null) {
layersCountToFree --;
DirectMemUtil.free(layer);
if(layersCountToFree == 0) {
break;
}
}
}
layersCache.trim();
}
// generate the layer
layer = (MappedByteBuffer) ByteBuffer.allocateDirect(layerSize);
final long layerSeed = Long.reverseBytes(
(xorShift(getInitialSeed()) << layerIndex) ^ layerIndex
);
generateData(layer, layerSeed);
layersCache.put(layerIndex - 1, layer);
}
return layer;
}