当前位置: 首页>>代码示例>>Java>>正文


Java Object2ObjectOpenHashMap.put方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java Object2ObjectOpenHashMap.put方法的具体用法?Java Object2ObjectOpenHashMap.put怎么用?Java Object2ObjectOpenHashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap的用法示例。


在下文中一共展示了Object2ObjectOpenHashMap.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assignClosest

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
/**
 * Returns the closest word in the vector file
 * @param map vectors
 * @param words input words
 * @return a list of closest words to the input ones
 */
public Object2ObjectOpenHashMap<String, ClusterEntry> assignClosest( final UncompressedWordVectors map, ArrayList<String> words ) {
    final int d = map.getVectorLength();
    Object2ObjectOpenHashMap<String, ClusterEntry> assignment = new Object2ObjectOpenHashMap<String, ClusterEntry>();
    for( String w : map.vectors.keySet() ) {
        float maxSim = -1;
        int bestWord = -1;
        for( int j = 0; j < words.size(); j++ ) {
            final float s = sim( map.vectors.get( w ), map.vectors.get( words.get( j ) ), d );
            if( s > maxSim ) {
                maxSim = s;
                bestWord = j;
            }
        }
        ClusterEntry e = new ClusterEntry();
        e.cluster = bestWord;
        e.score = maxSim;
        assignment.put( w, e );
    }
    return assignment;
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:27,代码来源:WordVectorsUtils.java

示例2: read

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
public static UncompressedWordVectors read( String file ) throws IOException {
    Object2ObjectOpenHashMap<String, float[]> map = new Object2ObjectOpenHashMap<String, float[]>();
    final BufferedReader lines = new BufferedReader( new FileReader( file ) );
    String line;
    while( ( line = lines.readLine() ) != null ) {
        String parts[] = line.split( "\t" );
        float[] values = new float[ parts.length - 1 ];
        for( int i = 1; i < parts.length; i++ ) {
            values[ i - 1 ] = Float.parseFloat( parts[ i ] );
        }
        map.put( parts[ 0 ], values );
    }
    lines.close();
    UncompressedWordVectors vector = new UncompressedWordVectors();
    vector.vectors = map;
    return vector;
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:18,代码来源:UncompressedWordVectors.java

示例3: generateNextLevel

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
private void generateNextLevel() {
        // System.out.println("Start generateNextLevel");
        level0 = level1;
        level1 = null;
        System.gc();

        Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper>();

        buildPrefixBlocks();

        for (ObjectArrayList<OpenBitSet> prefix_block_list : prefix_blocks.values()) {

            // continue only, if the prefix_block contains at least 2 elements
            if (prefix_block_list.size() < 2) {
                continue;
            }

            ObjectArrayList<OpenBitSet[]> combinations = getListCombinations(prefix_block_list);
            for (OpenBitSet[] c : combinations) {
                OpenBitSet X = (OpenBitSet) c[0].clone();
                X.or(c[1]);

                if (checkSubsets(X)) {
                    StrippedPartition st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition());
                    OpenBitSet rhsCandidates = new OpenBitSet();
//					 rhsCandidates.set(1, numberAttributes+1);

                    CombinationHelper ch = new CombinationHelper();
                    ch.setPartition(st);
                    ch.setRhsCandidates(rhsCandidates);

                    new_level.put(X, ch);
                }
            }
        }

        level1 = new_level;
    }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:39,代码来源:TaneAlgorithmFilterTreeEnd.java

示例4: generateNextLevel

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
private void generateNextLevel() {
        // System.out.println("Start generateNextLevel");
        level0 = level1;
        level1 = null;
        System.gc();

        Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper>();

        buildPrefixBlocks();

        for (ObjectArrayList<OpenBitSet> prefix_block_list : prefix_blocks.values()) {

            // continue only, if the prefix_block contains at least 2 elements
            if (prefix_block_list.size() < 2) {
                continue;
            }

            ObjectArrayList<OpenBitSet[]> combinations = getListCombinations(prefix_block_list);
            for (OpenBitSet[] c : combinations) {
                OpenBitSet X = (OpenBitSet) c[0].clone();
                X.or(c[1]);

                if (checkSubsets(X)) {
                    StrippedPartition st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition());
                    OpenBitSet rhsCandidates = new OpenBitSet();
//					 rhsCandidates.set(1, numberAttributes+1);

                    CombinationHelper ch = new CombinationHelper();
                    ch.setPartition(st);
                    ch.setRhsCandidates(rhsCandidates);

                    new_level.put(X, ch);
                }
            }
        }

        level1 = new_level;
//		System.out.println("Finished generateNextLevel");
    }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:40,代码来源:TaneAlgorithmFilterTreeDirect.java

示例5: readProperties

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
private Object2ObjectOpenHashMap<String,DataRef> readProperties(Input reader) {
    BinaryCoreReader propreader = new BinaryCoreReader(reader);
    Object2ObjectOpenHashMap<String,DataRef> props = new Object2ObjectOpenHashMap<>();
    int numProperties = reader.readInt();
    for(int i = 0; i < numProperties; i++) {
        String key = reader.readString();

        DataRef value = propreader.read();
        props.put(key, value);
    }

    return props;
}
 
开发者ID:marcusklang,项目名称:docforia,代码行数:14,代码来源:MemoryBinaryV1L0Codec.java

示例6: readProperties

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
public Object2ObjectOpenHashMap<String,DataRef> readProperties(JsonNode propNode) {
    Object2ObjectOpenHashMap<String,DataRef> map = new Object2ObjectOpenHashMap<>();

    Iterator<Map.Entry<String, JsonNode>> fieldIter = propNode.fields();
    while(fieldIter.hasNext()) {
        Map.Entry<String, JsonNode> entry = fieldIter.next();

        map.put(entry.getKey(), reader.read(entry.getValue()));
    }

    return map;
}
 
开发者ID:marcusklang,项目名称:docforia,代码行数:13,代码来源:MemoryJsonLevel0Codec.java

示例7: initializeGrids

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
public void initializeGrids(
		Set<UUID> allActiveNodes, 
		Set<UUID> activeNeedsInputNodes, 
		Set<UUID> passiveNodes,
		Object2IntOpenHashMap<UUID> uuidToIntMap,
		Object2ObjectOpenHashMap<UUID, Commodity[]> uuidOutputMap,
		Object2ObjectOpenHashMap<UUID, Commodity[]> uuidInputMap) {
	
	Object2IntOpenHashMap<UUID> uuidToIntMapWithMeter = new Object2IntOpenHashMap<UUID>(uuidToIntMap);
	uuidToIntMapWithMeter.put(meterUUID, uuidToIntMap.size());
	
	Object2ObjectOpenHashMap<UUID, Commodity[]> uuidOutputMapWithMeter = new Object2ObjectOpenHashMap<UUID, Commodity[]>(uuidOutputMap);
	uuidOutputMapWithMeter.put(meterUUID, Commodity.values());
	
	Object2ObjectOpenHashMap<UUID, Commodity[]> uuidInputMapWithMeter = new Object2ObjectOpenHashMap<UUID, Commodity[]>(uuidInputMap);
	uuidInputMapWithMeter.put(meterUUID, Commodity.values());
	
	
	for (Entry<EnergySimulationTypes,EnergyGrid> grid : grids.entrySet()) {
		grid.getValue().initializeGrid(allActiveNodes, activeNeedsInputNodes, passiveNodes, uuidToIntMapWithMeter, uuidOutputMapWithMeter);
	}
	
	ObjectOpenHashSet<UUID> passiveWithMeter = new ObjectOpenHashSet<UUID>(passiveNodes);
	passiveWithMeter.add(meterUUID);
	
	a2pInputStateMap = new UUIDCommodityMap(passiveWithMeter, uuidToIntMapWithMeter, uuidInputMapWithMeter, true);
	
	p2aInputStateMap = new UUIDCommodityMap(activeNeedsInputNodes, uuidToIntMap, uuidInputMap, true);
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:30,代码来源:OCEnergySimulationCore.java

示例8: generateNextLevel

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
private void generateNextLevel() {
    level0 = level1;
    level1 = null;
    System.gc();

    Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper> new_level = new Object2ObjectOpenHashMap<OpenBitSet, CombinationHelper>();

    buildPrefixBlocks();

    for (ObjectArrayList<OpenBitSet> prefix_block_list : prefix_blocks.values()) {

        // continue only, if the prefix_block contains at least 2 elements
        if (prefix_block_list.size() < 2) {
            continue;
        }

        ObjectArrayList<OpenBitSet[]> combinations = getListCombinations(prefix_block_list);
        for (OpenBitSet[] c : combinations) {
            OpenBitSet X = (OpenBitSet) c[0].clone();
            X.or(c[1]);

            if (checkSubsets(X)) {
                StrippedPartition st = null;
                CombinationHelper ch = new CombinationHelper();
                if (level0.get(c[0]).isValid() && level0.get(c[1]).isValid()) {
                    st = multiply(level0.get(c[0]).getPartition(), level0.get(c[1]).getPartition());
                } else {
                    ch.setInvalid();
                }
                OpenBitSet rhsCandidates = new OpenBitSet();

                ch.setPartition(st);
                ch.setRhsCandidates(rhsCandidates);

                new_level.put(X, ch);
            }
        }
    }

    level1 = new_level;
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:42,代码来源:TaneAlgorithm.java

示例9: cluster

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
public Object2ObjectOpenHashMap<String, ClusterEntry> cluster( final int k, final UncompressedWordVectors map, int[] originalAssigment, String[] words ) {
    final int N = words.length;
    int z = 0;
    final int d = map.N;
    float[][] x = new float[ N ][];

    for( z = 0; z < N; z++ ) {
        x[ z ] = map.vectors.get( words[ z ] );
    }
    final int maxiter = 100;
    Object2ObjectOpenHashMap<String, ClusterEntry> clusters = new Object2ObjectOpenHashMap<String, ClusterEntry>();
    //compute original centroids
    float[][] centroids = computeCentroids( x, k, d, N, originalAssigment );

    int[] assignment = new int[ N ];
    boolean done = false;
    int iterations = 0;
    while( !done ) {
        boolean change = false;
        int[] newAssignment = new int[ N ];
        for( int i = 0; i < N; i++ ) {
            float maxSim = -1;
            int bestCentroid = 0;
            for( int j = 0; j < k; j++ ) {
                final float s = sim( centroids[ j ], x[ i ], d );
                if( s > maxSim ) {
                    maxSim = s;
                    bestCentroid = j;
                }
            }
            newAssignment[ i ] = bestCentroid;
            if( bestCentroid != assignment[ i ] ) change = true;
        }
        assignment = newAssignment;
        if( iterations++ > maxiter || !change ) done = true;
        //recompute the centroids

        centroids = computeCentroids( x, k, d, N, newAssignment );
    }
    //build the output
    for( int i = 0; i < N; i++ ) {
        ClusterEntry e = new ClusterEntry();
        e.cluster = assignment[ i ];
        e.score = sim( centroids[ assignment[ i ] ], x[ i ], d );
        clusters.put( words[ i ], e );
    }
    return clusters;
}
 
开发者ID:yahoo,项目名称:FEL,代码行数:49,代码来源:WordVectorsUtils.java

示例10: addPartitionMessages

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
@Override
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE",
        justification="I know what I am doing")
public void addPartitionMessages( int partitionId, VertexIdMessages<I, M> messages) throws IOException {

    Object2ObjectOpenHashMap<I,DataInputOutput[]> partitionMap = new_map[partitionId];


    VertexIdMessageIterator<I, M> vertexIdMessageIterator = messages.getVertexIdMessageIterator();
    while (vertexIdMessageIterator.hasNext()) {
        vertexIdMessageIterator.next();
        I vertex_id = vertexIdMessageIterator.releaseCurrentVertexId();
        DataInputOutput[] vertex_map_entry = partitionMap.get(vertex_id);
        if (vertex_map_entry == null) {
            reentrant_locks[partitionId].writeLock().lock();
            try {
                if (vertex_map_entry == null) {
                    vertex_map_entry = new DataInputOutput[2];
                    partitionMap.put(vertex_id, vertex_map_entry);
                    vertex_map_entry[0] = (config.createMessagesInputOutput());
                    vertex_map_entry[1] = (config.createMessagesInputOutput());
                    setCurrentIndex(partitionId, vertex_id, 0);
                }
            }
            finally {
                reentrant_locks[partitionId].writeLock().unlock();
            }
        }
        reentrant_locks[partitionId].readLock().lock();
        synchronized (vertex_map_entry) {
            try {
                DataInputOutput dataInputOutput = vertex_map_entry[getCurrentIndex(partitionId, vertex_id)];
                VerboseByteStructMessageWrite.verboseWriteCurrentMessage(vertexIdMessageIterator,
                        dataInputOutput.getDataOutput());
                synchronized (has_messages_map[partitionId]) {
                    has_messages_map[partitionId].put(vertex_id, true);
                }
            } finally {
                reentrant_locks[partitionId].readLock().unlock();
            }
        }
    }

}
 
开发者ID:wmoustafa,项目名称:granada,代码行数:45,代码来源:ByteArrayMessagesPerVertexStore.java

示例11: addPartitionMessages

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; //导入方法依赖的package包/类
@Override
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE",
        justification="I know what I am doing")
public void addPartitionMessages( int partitionId, VertexIdMessages<I, M> messages) throws IOException {

    Object2ObjectOpenHashMap<I,M[]> partitionMap = new_map[partitionId];


    VertexIdMessageIterator<I, M> vertexIdMessageIterator = messages.getVertexIdMessageIterator();
    while (vertexIdMessageIterator.hasNext()) {
        vertexIdMessageIterator.next();

        I vertex_id = vertexIdMessageIterator.releaseCurrentVertexId();
        M[] vertex_map_entry = partitionMap.get(vertex_id);
        if (vertex_map_entry == null) {
            reentrant_locks[partitionId].writeLock().lock();
            try {
                if (vertex_map_entry == null) {
                    vertex_map_entry = (M[]) new Writable[2];
                    partitionMap.put(vertex_id, vertex_map_entry);
                    vertex_map_entry[0] = messageCombiner.createInitialMessage();
                    vertex_map_entry[1] = messageCombiner.createInitialMessage();
                    setCurrentIndex(partitionId, vertex_id, 0);

                }
            } finally {
                reentrant_locks[partitionId].writeLock().unlock();
            }
        }
        reentrant_locks[partitionId].readLock().lock();
        synchronized (vertex_map_entry) {
            try {
                messageCombiner.combine(vertex_id, vertex_map_entry[getCurrentIndex(partitionId, vertex_id)],
                        vertexIdMessageIterator.getCurrentMessage());
                synchronized (has_messages_map[partitionId]) {
                    has_messages_map[partitionId].put(vertex_id, true);
                }
            } finally {
                reentrant_locks[partitionId].readLock().unlock();
            }
        }
    }
}
 
开发者ID:wmoustafa,项目名称:granada,代码行数:44,代码来源:OneMessagePerVertexStore.java


注:本文中的it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。