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


Java HashSet.isEmpty方法代码示例

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


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

示例1: matches

import java.util.HashSet; //导入方法依赖的package包/类
@Override
public boolean matches(Object o) {
  ContainerLocalizationRequestEvent evt =
      (ContainerLocalizationRequestEvent) o;
  final HashSet<LocalResourceRequest> expected =
      new HashSet<LocalResourceRequest>(resources);
  for (Collection<LocalResourceRequest> rc : evt.getRequestedResources()
      .values()) {
    for (LocalResourceRequest rsrc : rc) {
      if (!expected.remove(rsrc)) {
        return false;
      }
    }
  }
  return expected.isEmpty();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestContainer.java

示例2: createImports

import java.util.HashSet; //导入方法依赖的package包/类
protected static void createImports(PrintWriter out, List<GeneratedPlugin> plugins) {
    out.printf("import jdk.vm.ci.meta.ResolvedJavaMethod;\n");
    out.printf("import org.graalvm.compiler.serviceprovider.ServiceProvider;\n");
    out.printf("\n");
    out.printf("import org.graalvm.compiler.nodes.ValueNode;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;\n");
    out.printf("import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory;\n");

    HashSet<String> extra = new HashSet<>();
    for (GeneratedPlugin plugin : plugins) {
        plugin.extraImports(extra);
    }
    if (!extra.isEmpty()) {
        out.printf("\n");
        for (String i : extra) {
            out.printf("import %s;\n", i);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:PluginGenerator.java

示例3: main

import java.util.HashSet; //导入方法依赖的package包/类
public static void main(String[] args) {
    Scanner scann = new Scanner(System.in);
    HashSet<String> nums = new HashSet<>();
    String[] input;
    while(!(input = scann.nextLine().split(", "))[0].equals("END")){
        if(input[0].equals("IN")){
            nums.add(input[1]);
        } else {
            nums.remove(input[1]);
        }
    }
    if(nums.isEmpty()){
        System.out.println("Parking Lot is Empty");

    } else {
        for (String num :
                nums) {
            System.out.println(num);
        }
    }


}
 
开发者ID:kostovhg,项目名称:SoftUni,代码行数:24,代码来源:p04_ParkingLot.java

示例4: removeObjectFromAllLists

import java.util.HashSet; //导入方法依赖的package包/类
public static void removeObjectFromAllLists(SceneObject removeThis) {

		//all the objects types
		HashSet<SceneObjectType> objectstypes = removeThis.getObjectsCurrentState().getObjectCapabilities();

		for (SceneObjectType type : objectstypes) {

			HashSet<SceneObject> objectssharingname   = object_database_table.get(type, removeThis.getObjectsCurrentState().ObjectsName.toLowerCase());
			if (objectssharingname!=null){
				objectssharingname.remove(removeThis);
				if (objectssharingname.isEmpty()){
					object_database_table.remove(type, objectssharingname);
				}
			}
		}


	}
 
开发者ID:ThomasWrobel,项目名称:JAMCore,代码行数:19,代码来源:SceneObjectDatabase_newcore.java

示例5: validate

import java.util.HashSet; //导入方法依赖的package包/类
private void validate() throws BuilderValidationException {
    HashSet<String> failures = new HashSet<>(3);

    if (syncDate == null) {
        syncDate = OffsetDateTime.now(ZoneId.of("UTC"));
    }

    if (isBlank(ldapServer)) {
        failures.add("No ldap server in entry!");
    }

    if (isBlank(dn)) {
        failures.add("No DN in entry!");
    }

    if (isBlank(ocpName)) {
        failures.add("No OCP group name given!");
    }

    if (! failures.isEmpty()) {
        throw new BuilderValidationException(User.class, failures);
    }
}
 
开发者ID:klenkes74,项目名称:openshift-ldapsync,代码行数:24,代码来源:GroupBuilder.java

示例6: loadProjects

import java.util.HashSet; //导入方法依赖的package包/类
public static void loadProjects(LinkedList<Projet> projects){
	HashSet<String> projectNames = loadProjectsNames();
	
	
	if(projectNames.isEmpty()){
		// For debug purposes
		System.out.println("No projects to load");
	}else{
		System.out.println("Loading projects");
		for (String s : projectNames) {
			if(s.contains(Projet.FORMAT)) {
				projects.add(Projet.load(s));
			}
		}
	}
}
 
开发者ID:coco35700,项目名称:uPMT,代码行数:17,代码来源:Utils.java

示例7: clear

import java.util.HashSet; //导入方法依赖的package包/类
@Override
public void clear(Circuit circuit) {
	HashSet<Component> comps = new HashSet<Component>(circuit.getNonWires());
	comps.addAll(circuit.getWires());
	if (!comps.isEmpty())
		modified.add(circuit);
	log.add(CircuitChange.clear(circuit, comps));

	ReplacementMap repl = new ReplacementMap();
	for (Component comp : comps)
		repl.remove(comp);
	getMap(circuit).append(repl);

	circuit.mutatorClear();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:CircuitMutatorImpl.java

示例8: changeRedstoneState

import java.util.HashSet; //导入方法依赖的package包/类
public void changeRedstoneState(boolean newState)
{
    if(newState)
    {
        playedTracks.clear();
        if(repeat != 2)
        {
            if(shuffle && !tracks.isEmpty())
            {
                playlistIndex = getWorld().rand.nextInt(tracks.size());
            }
            else
            {
                playlistIndex = 0;
            }
        }
    }
    else
    {
        Track track = Clef.eventHandlerServer.getTrackPlayedByPlayer(this);
        if(track != null)
        {
            HashSet<BlockPos> players = track.instrumentPlayers.get(getWorld().provider.getDimension());
            if(players != null)
            {
                players.remove(getPos());
                if(players.isEmpty())
                {
                    track.instrumentPlayers.remove(getWorld().provider.getDimension());
                }
            }
            if(!track.hasObjectsPlaying())
            {
                track.stop();
            }
            Clef.channel.sendToAll(new PacketPlayingTracks(track));
        }
    }
}
 
开发者ID:iChun,项目名称:Clef,代码行数:40,代码来源:TileEntityInstrumentPlayer.java

示例9: process

import java.util.HashSet; //导入方法依赖的package包/类
@Override
protected void process(DistributionMessage msg, boolean warn) {
  if (msg instanceof CompactResponse) {
    final HashSet<PersistentID> persistentIds = ((CompactResponse) msg).getPersistentIds();
    if (persistentIds != null && !persistentIds.isEmpty()) {
      results.put(msg.getSender(), persistentIds);
    }
  }
  super.process(msg, warn);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:CompactRequest.java

示例10: process

import java.util.HashSet; //导入方法依赖的package包/类
@Override
protected void process(DistributionMessage msg, boolean warn) {
  if (msg instanceof PrepareBackupResponse) {
    final HashSet<PersistentID> persistentIds =
        ((PrepareBackupResponse) msg).getPersistentIds();
    if (persistentIds != null && !persistentIds.isEmpty()) {
      results.put(msg.getSender(), persistentIds);
    }
  }
  super.process(msg, warn);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:PrepareBackupRequest.java

示例11: sendSyncObj

import java.util.HashSet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static boolean sendSyncObj(SyncParam syncParam) {
    HashSet<ModelSyncable> modelHashSet = (HashSet<ModelSyncable>) syncParam.baseDao.getSetBySyncStatus();
    if (modelHashSet == null || modelHashSet.isEmpty()) return true;

    HashSet<ModelSyncable> modelsToUpdate = new HashSet<>();
    for (ModelSyncable model : modelHashSet) {
        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation().create();

        String rawJson = gson.toJson(model);
        if(!model.getIdServer().contains("-")){
            syncParam.insertHttpRequest.setId(model.getIdServer());
            syncParam.insertHttpRequest.setMethod(HttpRequest.PUT_METHOD);
        }
        else {
            syncParam.insertHttpRequest.setId(null);
            syncParam.insertHttpRequest.setMethod(HttpRequest.POST_METHOD);
        }
        syncParam.insertHttpRequest.setRawJson(rawJson);
        String jsonResponse = HttpService.consume(syncParam.insertHttpRequest);
        if (jsonResponse == null) return false;

        try {
            JSONObject jsonObject = new JSONObject(jsonResponse);
            if (jsonObject.isNull("id")) return false;

            String idServer = jsonObject.getString("id");
            if (idServer.isEmpty()) return false;
            model.setIdServer(idServer);
            model.setSyncStatus(ModelSyncable.SYNC_REALIZED_STATUS);
            modelsToUpdate.add(model);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    return !modelsToUpdate.isEmpty() && syncParam.baseDao.updateAfterSync(modelsToUpdate);
}
 
开发者ID:alexandregpereira,项目名称:goblin-lib,代码行数:40,代码来源:SyncServerHelper.java

示例12: computeUnavailablility

import java.util.HashSet; //导入方法依赖的package包/类
private void computeUnavailablility(org.unitime.timetable.model.Exam exam, Long periodId, Hashtable<Long, Set<Meeting>> period2meetings) {
    if (period2meetings==null) {
        computeUnavailablility(exam, periodId);
    } else {
        Set<Meeting> meetings = period2meetings.get(periodId);
        if (meetings!=null) {
            meetings: for (Meeting meeting: meetings) {
                for (Iterator i=iDirects.iterator();i.hasNext();) {
                    DirectConflict dc = (DirectConflict)i.next();
                    if (meeting.getEvent().getUniqueId().equals(dc.getOtherEventId())) {
                        dc.addMeeting(meeting);
                        continue meetings;
                    }
                }
                HashSet<Long> students = new HashSet();
                for (Iterator i=meeting.getEvent().getStudentIds().iterator();i.hasNext();) {
                    Long studentId = (Long)i.next();
                    for (ExamSectionInfo section: getSections()) 
                        if (section.getStudentIds().contains(studentId)) {
                            students.add(studentId); break;
                        }
                }
                if (!students.isEmpty()) iDirects.add(new DirectConflict(meeting, students));
            }
        }
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:28,代码来源:ExamAssignmentInfo.java

示例13: checkFileInPattern

import java.util.HashSet; //导入方法依赖的package包/类
public static boolean checkFileInPattern(HashSet<Pattern> patterns, String key) {
    if (!patterns.isEmpty()) {
        Iterator<Pattern> it = patterns.iterator();
        while (it.hasNext()) {
            if (((Pattern) it.next()).matcher(key).matches()) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:ShareResPatchInfo.java

示例14: removeFromInstallQueue

import java.util.HashSet; //导入方法依赖的package包/类
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
        UserHandleCompat user) {
    if (packageNames.isEmpty()) {
        return;
    }
    SharedPreferences sp = Utilities.getPrefs(context);
    synchronized(sLock) {
        Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
        if (DBG) {
            Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
                    + ", removing packages: " + packageNames);
        }
        if (strings != null) {
            Set<String> newStrings = new HashSet<String>(strings);
            Iterator<String> newStringsIter = newStrings.iterator();
            while (newStringsIter.hasNext()) {
                String encoded = newStringsIter.next();
                PendingInstallShortcutInfo info = decode(encoded, context);
                if (info == null || (packageNames.contains(info.getTargetPackage())
                        && user.equals(info.user))) {
                    newStringsIter.remove();
                }
            }
            sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).apply();
        }
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:28,代码来源:InstallShortcutReceiver.java

示例15: getDesignatedLeader

import java.util.HashSet; //导入方法依赖的package包/类
/** In a reconfig operation, this method attempts to find the best leader for next configuration.
 *  If the current leader is a voter in the next configuartion, then it remains the leader.
 *  Otherwise, choose one of the new voters that acked the reconfiguartion, such that it is as   
 * up-to-date as possible, i.e., acked as many outstanding proposals as possible.
 *  
 * @param reconfigProposal
 * @param zxid of the reconfigProposal
 * @return server if of the designated leader
 */

private long getDesignatedLeader(Proposal reconfigProposal, long zxid) {
   //new configuration
   Proposal.QuorumVerifierAcksetPair newQVAcksetPair = reconfigProposal.qvAcksetPairs.get(reconfigProposal.qvAcksetPairs.size()-1);        
   
   //check if I'm in the new configuration with the same quorum address - 
   // if so, I'll remain the leader    
   if (newQVAcksetPair.getQuorumVerifier().getVotingMembers().containsKey(self.getId()) && 
           newQVAcksetPair.getQuorumVerifier().getVotingMembers().get(self.getId()).addr.equals(self.getQuorumAddress())){  
       return self.getId();
   }
   // start with an initial set of candidates that are voters from new config that 
   // acknowledged the reconfig op (there must be a quorum). Choose one of them as 
   // current leader candidate
   HashSet<Long> candidates = new HashSet<Long>(newQVAcksetPair.getAckset());
   candidates.remove(self.getId()); // if we're here, I shouldn't be the leader
   long curCandidate = candidates.iterator().next();
   
   //go over outstanding ops in order, and try to find a candidate that acked the most ops.
   //this way it will be the most up-to-date and we'll minimize the number of ops that get dropped
   
   long curZxid = zxid + 1;
   Proposal p = outstandingProposals.get(curZxid);
           
   while (p!=null && !candidates.isEmpty()) {                              
       for (Proposal.QuorumVerifierAcksetPair qvAckset: p.qvAcksetPairs){ 
           //reduce the set of candidates to those that acknowledged p
           candidates.retainAll(qvAckset.getAckset());
           //no candidate acked p, return the best candidate found so far
           if (candidates.isEmpty()) return curCandidate;
           //update the current candidate, and if it is the only one remaining, return it
           curCandidate = candidates.iterator().next();
           if (candidates.size() == 1) return curCandidate;
       }      
       curZxid++;
       p = outstandingProposals.get(curZxid);
   }
   
   return curCandidate;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:50,代码来源:Leader.java


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