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


Python util.HashSet类代码示例

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


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

示例1: recordPropositions

 def recordPropositions(self):
     """ generated source for method recordPropositions """
     propositions = HashSet()
     for component in components:
         if isinstance(component, (Proposition, )):
             propositions.add(component)
     return propositions
开发者ID:hobson,项目名称:ggpy,代码行数:7,代码来源:PropNet.py

示例2: CyclicTypeRecorder

    class CyclicTypeRecorder(object):

        def __init__(self):
            self.count = 0
            self.elements = HashMap()
            self.used = HashSet()

        def push(self, t):
            self.count += 1
            self.elements[t] = self.count
            return self.count

        def pop(self, t):
            del self.elements[t]
            if t in self.used:
                self.used.remove(t)

        def visit(self, t):
            i = self.elements.get(t)
            if i is not None:
                self.used.add(t)
            return i

        def isUsed(self, t):
            return t in self.used
开发者ID:ariejdl,项目名称:pysonarsq,代码行数:25,代码来源:Type.py

示例3: getBestVariable

 def getBestVariable(self, functionalSentence, functionInfo):
     """ generated source for method getBestVariable """
     # If all the variables that can be set by the functional sentence are in
     # the varOrdering, we return null. Otherwise, we return one of
     # those with the largest domain.
     # The FunctionInfo is sentence-independent, so we need the context
     # of the sentence (which has variables in it).
     tuple_ = GdlUtils.getTupleFromSentence(functionalSentence)
     dependentSlots = functionInfo.getDependentSlots()
     if len(tuple_) != len(dependentSlots):
         raise RuntimeException("Mismatched sentence " + functionalSentence + " and constant form " + functionInfo)
     candidateVars = HashSet()
     i = 0
     while i < len(tuple_):
         if isinstance(term, (GdlVariable, )) and dependentSlots.get(i) and not self.varOrdering.contains(term) and self.varsToAssign.contains(term):
             candidateVars.add(term)
         i += 1
     # Now we look at the domains, trying to find the largest
     bestVar = None
     bestDomainSize = 0
     for var in candidateVars:
         if domainSize > bestDomainSize:
             bestVar = var
             bestDomainSize = domainSize
     return bestVar
开发者ID:hobson,项目名称:ggpy,代码行数:25,代码来源:IterationOrderCandidate.py

示例4: save_and_get_complex

def save_and_get_complex():
	'''Test saving entities containing mapped collection properties'''
	entity1 = TestEntities.ComplexEntity()
	entity1.setId("complex1")
	strings = ArrayList()
	strings.add("one")
	strings.add("two")
	entity1.setStringList(strings)
	ints = HashSet()
	ints.add(1)
	ints.add(2)
	entity1.setIntSet(ints)
	extended = HashMap()
	extended.put("prop1", "one")
	extended.put("prop2", "two")
	entity1.setExtendedProps(extended)
	
	service = EntityService(TestEntities.ComplexEntity)
	service.save(entity1)
	
	entity2 = service.get("complex1")
	assertNotNull(entity2)
	assertEquals(entity2.getId(), entity1.getId())
	assertTrue(entity2.getStringList().contains("one"))
	assertTrue(entity2.getStringList().contains("two"))
	assertTrue(entity2.getIntSet().contains(java.lang.Long(1)))
	assertTrue(entity2.getIntSet().contains(java.lang.Long(2)))
	assertNotNull(entity2.getExtendedProps())
	assertEquals(entity2.getExtendedProps().get("prop1"), "one")
	assertEquals(entity2.getExtendedProps().get("prop2"), "two")
开发者ID:ScottWang,项目名称:meetup.beeno,代码行数:30,代码来源:test_entity_io.py

示例5: handleGrantNumber

 def handleGrantNumber(self):
     out = ByteArrayOutputStream()
     req = SearchRequest("grant_numbers:%s*" % self.term)
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         creatorResults = res.getResults()
         for creatorRes in creatorResults:
             creatorList = creatorRes.getList("grant_numbers")
             if (creatorList.isEmpty()==False):
                 for hit in creatorList:
                     hits.add(hit)
         self.writer.print("[")
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.print(",\"%s\"" % hit)
             else:    
                 self.writer.print("\"%s\"" % hit)
             hitnum += 1
         self.writer.print("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:nishen,项目名称:redbox,代码行数:28,代码来源:lookup.py

示例6: handleWorkflowStep

 def handleWorkflowStep(self):
     out = ByteArrayOutputStream()
     req = SearchRequest("workflow_step_label:[* TO *]" )
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         recordTypeResults = res.getResults()
         for recordTypeResult in recordTypeResults:
             recordTypeList = recordTypeResult.getList("workflow_step_label")
             if (recordTypeList.isEmpty()==False):
                 for hit in recordTypeList:
                     hits.add(hit)
         self.writer.println("[")
         
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.println(",{\"value\": \"%s\",\n\"label\": \"%s\"}" % (hit,hit))
             else:    
                 self.writer.println("{\"value\": \"%s\",\n\"label\": \"%s\"}" % (hit,hit))
             hitnum += 1
         self.writer.println("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:nishen,项目名称:redbox,代码行数:29,代码来源:lookup.py

示例7: updateDomains

 def updateDomains(self):
     """ generated source for method updateDomains """
     changedSomething = True
     while changedSomething:
         changedSomething = False
         for d in domains.values():
             for intSet in d.functionRefs:
                 for d2 in intSet:
                     if d2 != None:
                         if domain == None:
                             domain = HashSet(d2.values)
                         else:
                             domain.retainAll(d2.values)
                 if domain != None:
                     d.values.addAll(domain)
             if d.loc != None:
                 if name == "does":
                     newLoc.name = GdlPool.getConstant("legal")
                     newLoc.idx = d.loc.idx
                     if otherDom == None:
                         raise RuntimeException("Uh oh, missed a legal")
                     d.values.addAll(otherDom.values)
                 elif name == "true":
                     newLoc.name = GdlPool.getConstant("next")
                     newLoc.idx = d.loc.idx
                     if otherDom == None:
                         raise RuntimeException("Uh oh, missed a next")
                     d.values.addAll(otherDom.values)
             if len(d.values) != before:
                 changedSomething = True
开发者ID:hobson,项目名称:ggpy,代码行数:30,代码来源:PropNetAnnotater.py

示例8: __init__

    def __init__(self, client_addr, server_addr, operations_map, is_simulator=False):
        self.client_addr = client_addr
        self.server_addr = server_addr
        self.is_simulator = is_simulator

        self.operations = dict(operations_map)
        self.operations["help"] = "help <optional command>"
        self.operations["login"] = "login username"
        self.operations["logout"] = "logout"
        self.operations["echo"] = "echo text"
        self.operations["exit"] = "exit"

        self.aux_commands = {"help", "login", "logout", "echo", "exit"}

        self.op_commands = set(operations_map.keySet())
        self.all_commands = set(self.op_commands)
        self.all_commands.update(self.aux_commands)

        all_commands_set = HashSet()
        for x in self.all_commands:
            all_commands_set.add(x)

        try:
            self.console = ConsoleReader()
            self.console.addCompleter(StringsCompleter(all_commands_set))
            self.console.setPrompt("prompt> ")
        except IOException as err:
            err.printStackTrace()
开发者ID:kourge,项目名称:chitter,代码行数:28,代码来源:pyconsole.py

示例9: handleQuery

 def handleQuery(self, query, fieldName, formatStr):
     out = ByteArrayOutputStream()
     req = SearchRequest(query)
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         results = res.getResults()
         for searchRes in results:
             searchResList = searchRes.getList(fieldName)
             if (searchResList.isEmpty()==False):
                 for hit in searchResList:
                     if self.term is not None:
                         if hit.find(self.term) != -1:
                             hits.add(hit)
                     else:
                         hits.add(hit)
         self.writer.print("[")
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.print(","+formatStr % {"hit":hit})
             else:    
                 self.writer.print(formatStr % {"hit":hit})
             hitnum += 1
         self.writer.print("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:32,代码来源:lookup.py

示例10: getNodeObjects

def getNodeObjects(api, filters):
	found = 0
	ndMap = {}
	ndSet = HashSet()
	lanSwitchCapability = "com.hp.nnm.capability.node.lanswitching"
	ipForwardingCapability = "com.hp.nnm.capability.node.ipforwarding"

	try:
		ndStub = api.getStub(NnmServicesEnum().Node)
		for filter in filters:
			allNodesArray = ndStub.getNodes(filter)
			allNodes = allNodesArray.getItem()
			if allNodes != None:
				found = 1
				logger.debug("Retrieved %s Node Objects" % (len(allNodes)))
				for i in range(len(allNodes)):
					if (notNull(allNodes[i].getId())
							and notNull(allNodes[i].getName())
							and notNull(allNodes[i].getCreated()) and notNull(allNodes[i].getModified())):
						## Don't add duplicate Nodes
						if ndSet.contains(allNodes[i].getId()):
							continue
						else:
							ndSet.add(allNodes[i].getId())

							# The capabilities com.hp.nnm.capability.node.lanswitching and
							# com.hp.nnm.capability.node.ipforwarding have replaced isLanSwitch and isIPv4Router respectively.
							isLanSwitch = 0
							isRouter = 0
							caps = allNodes[i].getCapabilities()
							if (notNull(caps)):
								for cap in caps:
									key = cap.getKey().strip()
									if (key == lanSwitchCapability):
										isLanSwitch = 1
									if (key == ipForwardingCapability):
										isRouter = 1

							ndMap[allNodes[i].getId()] = UNode(allNodes[i].getId(), allNodes[i].getName(), isRouter,
												isLanSwitch, allNodes[i].getSystemName(), allNodes[i].getSystemContact(),
												allNodes[i].getSystemDescription(), allNodes[i].getSystemLocation(), allNodes[i].getSystemObjectId(),
												allNodes[i].getLongName(), allNodes[i].getSnmpVersion(), allNodes[i].getDeviceModel(),
												allNodes[i].getDeviceVendor(), allNodes[i].getDeviceFamily(), allNodes[i].getDeviceDescription(),
												allNodes[i].getDeviceCategory(), '', '')
			else:
				break
	except:
		stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
		errMsg = 'Exception:\n %s' % stacktrace
		logger.error(errMsg)
		api.Framework.reportWarning(errMsg)
	if found:
		logger.debug('Created a dictionary of %d Node objects' % (len(ndMap)))
	else:
		errMsg = 'Did not find any Node objects'
		logger.debug(errMsg)
		api.Framework.reportWarning(errMsg)

	return ndMap
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:59,代码来源:NNM_Integration_Utils.py

示例11: containers

def containers():
    result = HashSet()
    for _delta in specification.deltas:
        depl = _delta.deployedOrPrevious
        current_container = depl.container
        if depl.type in ("soa.CompositeSOADeployable","soa.Composite") and current_container.type in ("wls.Server",'wls.Cluster'):
            result.add(current_container)
    return result
开发者ID:wv0,项目名称:xld-oracle-soa-plugin,代码行数:8,代码来源:check-container-hostnames.py

示例12: getStateFromBase

 def getStateFromBase(self):
     """ generated source for method getStateFromBase """
     contents = HashSet()
     for p in propNet.getBasePropositions().values():
         p.setValue(p.getSingleInput().getValue())
         if p.getValue():
             contents.add(p.__name__)
     return MachineState(contents)
开发者ID:hobson,项目名称:ggpy,代码行数:8,代码来源:SamplePropNetStateMachine.py

示例13: deployeds

def deployeds():
    result = HashSet()
    for _delta in deltas.deltas:
        depl = _delta.deployedOrPrevious
        current_container = depl.container
        if _delta.operation != "NOOP" and depl.type == "soa.ExtensionLibrary" and current_container.type in ("wls.SOAServer",'wls.SOACluster'):
            result.add(depl)
    return result
开发者ID:sikendermd,项目名称:xld-oracle-soa-plugin,代码行数:8,代码来源:update-extension-library.py

示例14: getUncachedGameKeys

 def getUncachedGameKeys(self):
     """ generated source for method getUncachedGameKeys """
     theKeys = HashSet()
     for game in File("games/test").listFiles():
         if not game.__name__.endsWith(".kif"):
             continue 
         theKeys.add(game.__name__.replace(".kif", ""))
     return theKeys
开发者ID:hobson,项目名称:ggpy,代码行数:8,代码来源:TestGameRepository.py

示例15: getScripts

 def getScripts(self, menu):
     from java.util import HashSet
     scriptList = HashSet()
     if self.menuToProcMap.has_key(menu):
         menuItems = self.menuToProcMap[menu]
         for item in menuItems:
             scriptList.add(str(item))             
     return scriptList
开发者ID:KeithLatteri,项目名称:awips2,代码行数:8,代码来源:ProcedureInterface.py


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