Java 类com.google.inject.internal.Maps 实例源码

项目:Pogamut3    文件:RayCastBspStrategy.java   
/** Get node space of a node
 */
protected NodeSpace getNodeSpace( IConstBspNode<ArrayList<Triangle>, AxisAlignedPlane3D> node ) {
    if ( nodeSpaces == null ) {
        nodeSpaces = Maps.newHashMap();
    }

    if ( !nodeSpaces.containsKey(node) ) {
        if ( node.getParent() != null ) {
            IConstBspInternalNode<ArrayList<Triangle>, AxisAlignedPlane3D> parent = node.getParent();
            if ( parent.getNegativeChild() == node ) {
                nodeSpaces.put( node, getNodeSpace(parent).splitOffNegative(parent.getBoundary()) );
            } else {
                nodeSpaces.put( node, getNodeSpace(parent).splitOffPositive(parent.getBoundary()) );
            }
        } else {
            NodeSpace treeSpace = new NodeSpace(
                 Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
                 Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
                 Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY
            );
            for ( Triangle triangle : node.getSubtreeData() ) {
                for ( Point3D vertex : triangle.vertices ) {
                    treeSpace.expand( new Location( vertex ) );
                }
            }
            nodeSpaces.put( node, treeSpace );
        }
    }

    return nodeSpaces.get(node);
   }
项目:welshare    文件:UserDaoJpa.java   
@Override
public Map<String, SocialNetworkScore> getReputationScores(String userId) {
    QueryDetails details = new QueryDetails()
        .setQuery("SELECT snScore FROM SocialNetworkScore snScore where snScore.user.id = :userId")
        .setParamNames(new String[] {"userId"})
        .setParamValues(new Object[] {userId});

    List<SocialNetworkScore> scores = findByQuery(details);
    Map<String, SocialNetworkScore> map = Maps.newLinkedHashMap();
    for (SocialNetworkScore score : scores) {
        map.put(score.getSocialNetwork(), score);
    }
    return map;
}
项目:Pogamut3    文件:NavMeshAStarDistanceHeuristic.java   
protected void ensureTeleporterDistancesUpToDate( Location destination ) {
    if ( cachedDestination != null && cachedDestination.equals( destination ) ) {
        return;
    }

    cachedDestination = destination;

    // ensure teleporter locations have been initialized
    if ( teleporterToDistanceToCachedDestinationMap == null ) {
        teleporterToDistanceToCachedDestinationMap = Maps.newHashMap();
        for ( OffMeshPoint point : navMesh.getOffMeshPoints() ) {
            if ( point.getNavPoint().isTeleporter() ) {
                teleporterToDistanceToCachedDestinationMap.put( point, null );
            }
        }
    }

    // the complication here is that the agent may travel through multiple teleporters

    HashMap<Location, Double> sinkToDistanceMap = Maps.newHashMap();
    sinkToDistanceMap.put( destination, 0.0 );
    Set<OffMeshPoint> unusedTeleporters = Sets.newHashSet( teleporterToDistanceToCachedDestinationMap.keySet() );
    while ( unusedTeleporters.size() > 0 ) {
        // breadth search from the destination for the next closest teleport

        OffMeshPoint teleporterWithClosestExit = null;
        Double teleporterWithClosestExitCostEstimate = Double.POSITIVE_INFINITY;
        for ( OffMeshPoint candidateTeleporter : unusedTeleporters ) {
            assert( candidateTeleporter.getOutgoingEdges().size() == 1 ); // teleporter should have single exit
            Location candidateTeleporterExit = candidateTeleporter.getOutgoingEdges().iterator().next().getTo().getLocation();
            double candidateCostEstimate = Double.POSITIVE_INFINITY;
            for ( Entry<Location, Double> sinkEntry : sinkToDistanceMap.entrySet() ) {
                double sinkCostEstimate = candidateTeleporterExit.getDistance( sinkEntry.getKey() ) + sinkEntry.getValue();
                sinkCostEstimate = Math.min( candidateCostEstimate, sinkCostEstimate );
            }

            if ( candidateCostEstimate < teleporterWithClosestExitCostEstimate ) {
                teleporterWithClosestExit = candidateTeleporter;
                teleporterWithClosestExitCostEstimate = candidateCostEstimate;
            }
        }

        sinkToDistanceMap.put( teleporterWithClosestExit.getLocation(), teleporterWithClosestExitCostEstimate );
        teleporterToDistanceToCachedDestinationMap.put( teleporterWithClosestExit, teleporterWithClosestExitCostEstimate );
        unusedTeleporters.remove( teleporterWithClosestExit );
    }
}
项目:caarray    文件:FileAccessServiceStub.java   
/**
 * @return a DataStorageFacade that knows about a single storage engine - this stub class
 */
public DataStorageFacade createStorageFacade() {
    final Map<String, DataStorage> engines = Maps.newHashMap();
    engines.put(FileAccessServiceStub.SCHEME, this);
    return new DataStorageFacade(engines, FileAccessServiceStub.SCHEME, FileAccessServiceStub.SCHEME);
}