當前位置: 首頁>>代碼示例>>Java>>正文


Java HashSet.size方法代碼示例

本文整理匯總了Java中java.util.HashSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java HashSet.size方法的具體用法?Java HashSet.size怎麽用?Java HashSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.HashSet的用法示例。


在下文中一共展示了HashSet.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toString

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Brief description of this object.
 */
@Override
public synchronized String toString() {
    StringBuilder sb = new StringBuilder();

    sb.append(watch2Paths.size()).append(" connections watching ")
        .append(watchTable.size()).append(" paths\n");

    int total = 0;
    for (HashSet<String> paths : watch2Paths.values()) {
        total += paths.size();
    }
    sb.append("Total watches:").append(total);

    return sb.toString();
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:19,代碼來源:WatchManager.java

示例2: handleAddExpiringCourseNotification

import java.util.HashSet; //導入方法依賴的package包/類
@Override
protected Notification handleAddExpiringCourseNotification(Course course, Date today, Map messageParameters)
		throws Exception {
	org.phoenixctms.ctsms.enumeration.NotificationType notificationType = org.phoenixctms.ctsms.enumeration.NotificationType.EXPIRING_COURSE;
	ServiceUtil.cancelNotifications(course.getNotifications(), this, notificationType);
	Notification notification = Notification.Factory.newInstance();
	Department department = null;
	HashSet<Staff> lecturers = addLecturerRecipients(notification, course, false);
	if (lecturers.size() == 0) {
		department = course.getDepartment();
		notification.setDepartment(department);
	}
	notification.setCourse(course);
	course.addNotifications(notification);
	setRemainingFields(notification, today, notificationType, messageParameters);
	notification = this.create(notification);
	// if (lecturers.size() == 0) {
	// addDepartmentRecipients(notification, department, notificationType);
	// } else {
	createNotificationRecipients(notification, lecturers);
	// }
	return notification;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:24,代碼來源:NotificationDaoImpl.java

示例3: countClusters

import java.util.HashSet; //導入方法依賴的package包/類
public ClusterResult countClusters() {
	final HashMap<Long, DictNode> lookup = new HashMap<Long, DictNode>(this.nodes);
	int clusterCount = 0;
	int maxClusterSize = 0;
	int deadLinks = 0;
	final HashSet<Long> currentCluster = new HashSet<Long>();

	while (lookup.size() > 0) {
		DictNode r = (DictNode) lookup.values().toArray()[0];
		dfsMarking(r, currentCluster);
		if (currentCluster.size() > maxClusterSize) {
			maxClusterSize = currentCluster.size();
		}
		for (long c : currentCluster) {
			lookup.remove(c);
		}
		currentCluster.clear();
		clusterCount += 1;
	}

	return new ClusterResult(clusterCount, maxClusterSize, deadLinks);
}
 
開發者ID:Chat-Wane,項目名稱:peersim-pcbroadcast,代碼行數:23,代碼來源:DictGraph.java

示例4: main

import java.util.HashSet; //導入方法依賴的package包/類
public static void main(String[] args) throws NamingException {
	checkArgs(args);
	final Hashtable<String, String> jndiProperties = new Hashtable<>();
	jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
	final Context ic = new InitialContext(jndiProperties);

	Simple proxy = (Simple) ic.lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName());

	HashSet<String> serverList = new HashSet<>();

	for (int i = 0; i < 20; i++) {
		serverList.add(proxy.getJBossServerName());
	}

	if (serverList.size() > 1) {
		log.info("Server should be part of a cluster or multiple URL's as the invocation was executed on the following servers : " + serverList);
	} else if (serverList.size() == 1) {
		log.warning("Server is not part of a cluster with multiple nodes, or did not have multiple PROVIDER URL's, as the invocation was executed on a single server : " + new ArrayList<String>(serverList).get(0));
	} else {
		throw new RuntimeException("Unexpected result, no server list!");
	}
}
 
開發者ID:wfink,項目名稱:jboss-eap7.1-playground,代碼行數:23,代碼來源:LegacyClusterJBossEjbClient.java

示例5: chooseEnemy

import java.util.HashSet; //導入方法依賴的package包/類
@Override
protected Char chooseEnemy() {

	if (enemy == null || !enemy.isAlive()) {
		HashSet<Mob> enemies = new HashSet<Mob>();
		for (Mob mob : Dungeon.level.mobs) {
			if (mob.hostile && Level.fieldOfView[mob.pos]) {
				enemies.add(mob);
			}
		}

		enemy = enemies.size() > 0 ? Random.element(enemies) : null;
	}

	return enemy;
}
 
開發者ID:G2159687,項目名稱:ESPD,代碼行數:17,代碼來源:Lichen.java

示例6: startSearch

import java.util.HashSet; //導入方法依賴的package包/類
protected void startSearch(String SearchQuery) {
    Intent searchIntent = new Intent(this, SearchResultActivity.class);
    searchIntent.setAction(Intent.ACTION_SEARCH);
    Bundle bundle = new Bundle();
    bundle.putBoolean(ARG_IS_GLOBAL_SEARCH, true);
    ArrayList<Integer> selectedSearchableBooks = new ArrayList<>();

    if (shouldDisplayDownloadedOnly()) {
        selectedSearchableBooks.addAll(selectedBooksIds);
    } else {
        HashSet<Integer> downloadedHashSet = mBooksInformationDbHelper.getBookIdsDownloadedOnly();
        downloadedHashSet.retainAll(selectedBooksIds);

        if (downloadedHashSet.size() == 0) {
            Toast.makeText(this, R.string.no_downloaded_selected_books, Toast.LENGTH_SHORT).show();
            return;
        } else {
            if (downloadedHashSet.size() < selectedBooksIds.size()) {
                Toast.makeText(this, R.string.searching_downloaded_only, Toast.LENGTH_SHORT).show();
            }
            selectedSearchableBooks.addAll(downloadedHashSet);
        }
    }

    bundle.putIntegerArrayList(SearchResultFragment.ARG_SEARCHABLE_BOOKS, selectedSearchableBooks);
    bundle.putString(SearchManager.QUERY, SearchQuery);
    searchIntent.putExtras(bundle);

    startActivity(searchIntent);
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:31,代碼來源:BrowsingActivity.java

示例7: handleAddNotification

import java.util.HashSet; //導入方法依賴的package包/類
@Override
protected Notification handleAddNotification(
		VisitScheduleItem visitScheduleItem, Proband proband, ProbandStatusEntry probandStatusEntry, Date today, Map messageParameters)
				throws Exception {
	org.phoenixctms.ctsms.enumeration.NotificationType notificationType = org.phoenixctms.ctsms.enumeration.NotificationType.PROBAND_INACTIVE_VISIT_SCHEDULE_ITEM;
	ServiceUtil.cancelNotifications(visitScheduleItem.getNotifications(), this, notificationType);
	Notification notification = Notification.Factory.newInstance();
	Trial trial = visitScheduleItem.getTrial();
	Department department = null;
	HashSet<Staff> trialMembers = addTrialTeamMemberOtherRecipients(notification, trial, false);
	if (trialMembers.size() == 0) {
		department = trial.getDepartment();
		notification.setDepartment(department);
	}
	notification.setVisitScheduleItem(visitScheduleItem);
	visitScheduleItem.addNotifications(notification);
	notification.setProband(proband);
	proband.addNotifications(notification);
	notification.setProbandStatusEntry(probandStatusEntry);
	probandStatusEntry.addNotifications(notification);
	setRemainingFields(notification, today, notificationType, messageParameters);
	notification = this.create(notification);
	// if (trialMembers.size() == 0) {
	// addDepartmentRecipients(notification, department, notificationType);
	// } else {
	createNotificationRecipients(notification, trialMembers);
	// }
	return notification;
}
 
開發者ID:phoenixctms,項目名稱:ctsms,代碼行數:30,代碼來源:NotificationDaoImpl.java

示例8: main

import java.util.HashSet; //導入方法依賴的package包/類
public static void main(String[] args) throws NamingException {
	checkArgs(args);

	Properties p = new Properties();
	
	p.put(Context.INITIAL_CONTEXT_FACTORY, WildFlyInitialContextFactory.class.getName());
	p.put(Context.PROVIDER_URL, "http-remoting://localhost:8080,http-remoting://localhost:8180");
	p.put(Context.SECURITY_PRINCIPAL, "user1");
	p.put(Context.SECURITY_CREDENTIALS, "user1+");
	InitialContext ic = new InitialContext(p);
	
	final String lookup = "ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName();
	Simple proxy = (Simple) ic.lookup(lookup);
	log.fine("Proxy after lookup is : " + proxy);
	
	HashSet<String> serverList = new HashSet<>();

	log.info("Try to invoke SimpleBean with server @8080 @8180");
	try {
		for (int i = 0; i < 20; i++) {
			serverList.add(proxy.getJBossServerName());
			if(i == 0) log.fine("Proxy after first invocation is : " + proxy);
		}
	} catch (Exception e) {
		log.severe("Invocation failed! " + e.getMessage());
	}
	
	if(serverList.size() > 1) {
		log.info("Server should be part of a cluster as the invocation was executed on the following servers : " + serverList);
	}else if(serverList.size() == 1) {
		log.info("Server is not part of a cluster as the invocation was executed on a single server : " + new ArrayList<String>(serverList).get(0));
	}else{
		log.severe("No successfull invocation");
	}
}
 
開發者ID:wfink,項目名稱:jboss-eap7.1-playground,代碼行數:36,代碼來源:MultipleServerProviderURLClient.java

示例9: hasDuplicatePermissions

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Checks if same permission is sent more than once
 * @param locallySetPermissions
 * @return
 */
private boolean hasDuplicatePermissions(List<NodePermissions.NodePermission> locallySetPermissions)
{
    boolean duplicate = false;
    if (locallySetPermissions != null)
    {
        HashSet<NodePermissions.NodePermission> temp = new HashSet<>(locallySetPermissions.size());
        for (NodePermissions.NodePermission permission : locallySetPermissions)
        {
            temp.add(permission);
        }
        duplicate = (locallySetPermissions.size() != temp.size());
    }
    return duplicate;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:20,代碼來源:NodesImpl.java

示例10: removeWatcher

import java.util.HashSet; //導入方法依賴的package包/類
public synchronized void removeWatcher(Watcher watcher) {
    HashSet<String> paths = watch2Paths.remove(watcher);
    if (paths == null) {
        return;
    }
    for (String p : paths) {
        HashSet<Watcher> list = watchTable.get(p);
        if (list != null) {
            list.remove(watcher);
            if (list.size() == 0) {
                watchTable.remove(p);
            }
        }
    }
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:16,代碼來源:WatchManager.java

示例11: validateHole

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Validates only 1 vertex is tangential (shared) between the interior and exterior of a polygon
 */
protected void validateHole(BaseLineStringBuilder shell, BaseLineStringBuilder hole) {
    HashSet exterior = Sets.newHashSet(shell.points);
    HashSet interior = Sets.newHashSet(hole.points);
    exterior.retainAll(interior);
    if (exterior.size() >= 2) {
        throw new InvalidShapeException("Invalid polygon, interior cannot share more than one point with the exterior");
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:12,代碼來源:BasePolygonBuilder.java

示例12: randomNodes

import java.util.HashSet; //導入方法依賴的package包/類
public LinkedList<NetNode> randomNodes() {
	HashSet<Integer> hs = new HashSet<Integer>();
	LinkedList<NetNode> temp = new LinkedList<NetNode>();
	int size = nodes.size();
	while (hs.size() < size) {
		//replaced Math.random() code
		int index = (int)(engine.raw2() * size);
		int s = hs.size();
		hs.add(index);
		if (s < hs.size()) {
			temp.add(nodes.get(index));
		}
	}
	return temp;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:16,代碼來源:NodeList.java

示例13: removeLeastHotRecord

import java.util.HashSet; //導入方法依賴的package包/類
private void removeLeastHotRecord() {
	if (cm.hotChunkEnabled && hotChunkRecord.size() > cm.hotChunkMaxCount) {
		HashSet<ChunkInfo> removeSet = new HashSet<>();
		for (ChunkInfo chunkInfo : hotChunkRecord) {
			removeSet.add(chunkInfo);
			if (hotChunkRecord.size() - removeSet.size() <= cm.hotChunkMaxCount) {
				break;
			}
		}
		hotChunkRecord.removeAll(removeSet);

	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:14,代碼來源:HotChunkHolder.java

示例14: findNextServer

import java.util.HashSet; //導入方法依賴的package包/類
private ServerLocation findNextServer(Set<Map.Entry<ServerLocation, HashSet<Integer>>> entrySet,
    HashSet<Integer> currentBucketSet) {

  ServerLocation server = null;
  int max = -1;
  ArrayList<ServerLocation> nodesOfEqualSize = new ArrayList<ServerLocation>();
  for (Map.Entry<ServerLocation, HashSet<Integer>> entry : entrySet) {
    HashSet<Integer> buckets = new HashSet<Integer>();
    buckets.addAll(entry.getValue());
    buckets.removeAll(currentBucketSet);

    if (max < buckets.size()) {
      max = buckets.size();
      server = entry.getKey();
      nodesOfEqualSize.clear();
      nodesOfEqualSize.add(server);
    } else if (max == buckets.size()) {
      nodesOfEqualSize.add(server);
    }
  }

  // return node;
  Random r = new Random();
  if (nodesOfEqualSize.size() > 0) {
    return nodesOfEqualSize.get(r.nextInt(nodesOfEqualSize.size()));
  }

  return null;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:30,代碼來源:ClientMetadataService.java

示例15: GraphEdgeConnection

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Instantiates a new graph edge connection.
 */
public GraphEdgeConnection(NetworkModel networkModel, NetworkComponent networkComponent, GraphEdge graphEdge) {

	this.graphEdge = graphEdge;
	
	EdgeType edgeType = networkModel.getGraph().getEdgeType(this.graphEdge);
	
	if (networkComponent.isDirected() && edgeType==EdgeType.DIRECTED) {
		this.fixedDirected = true;	
		this.graphNode1 = networkModel.getGraph().getSource(this.graphEdge);
		this.graphNode2 = networkModel.getGraph().getDest(this.graphEdge);
		
	} else {
		this.fixedDirected = false;
		Pair<GraphNode> nodePair = networkModel.getGraph().getEndpoints(this.graphEdge);
		this.graphNode1 = nodePair.getFirst();
		this.graphNode2 = nodePair.getSecond();
	}
	
	HashSet<NetworkComponent> netComps = null; 
	
	netComps = networkModel.getNetworkComponents(this.graphNode1);
	netComps.remove(networkComponent);
	if (netComps.size()>0) {
		this.externalNetworkComponent1 = netComps.iterator().next();	
	}
	
	netComps = networkModel.getNetworkComponents(this.graphNode2);
	netComps.remove(networkComponent);
	if (netComps.size()>0) {
		this.externalNetworkComponent2 = netComps.iterator().next();	
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:36,代碼來源:GraphEdgeConnection.java


注:本文中的java.util.HashSet.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。