当前位置 : 主页 > 编程语言 > c++ >

基于委托的车辆追踪器

来源:互联网 收集:自由互联 发布时间:2021-06-30
基于委托的车辆追踪器 /** 基于委托的车辆追踪器 */public class DelegatingVehicleTracker {private final ConcurrentHashMap locations;private final Map unmodifiableMap; public DelegatingVehicleTracker(Map points) { locations
基于委托的车辆追踪器
/** 基于委托的车辆追踪器 */
public class DelegatingVehicleTracker {

	private final ConcurrentHashMap
 
   locations;
	
	private final Map
  
    unmodifiableMap; public DelegatingVehicleTracker(Map
   
     points) { locations = new ConcurrentHashMap
    
     (); unmodifiableMap = Collections.unmodifiableMap(locations); } public Map
     
       getLocations() { return unmodifiableMap; } public Point getLocation(String id) { return locations.get(id); } public void setLocation(String id, int x, int y) { if (locations.replace(id, new Point(x, y)) != null) System.out.println("invalid vehicle name : " + id); } }
     
    
   
  
 
网友评论