本文整理汇总了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();
}
示例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;
}
示例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);
}
示例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!");
}
}
示例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;
}
示例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);
}
示例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;
}
示例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");
}
}
示例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;
}
示例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);
}
}
}
}
示例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");
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
}