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


Python HashSet.addAll方法代码示例

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


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

示例1: findMessages

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
def findMessages(mc,custid,count, includeCategorizedRecipients=False):
    print 'findMessages() should find ',count
    amsm = mc.getActiveMailboxStoreManager()
    msgs = HashSet()
    retries = 15

    while msgs.size() < count and retries > 0:
        for p in mc.getPartitionManager().listPartitions():
            if p.isReadOnly():
                continue
            print 'searching for messages to be stored in',p
            tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p,includeCategorizedRecipients)
            if tm.size() > 0:
                 msgs.addAll(tm)

        if msgs.size() < count:
            time.sleep(10)
        retries = retries - 1

        print 'findMessages() found',msgs.size()

    if msgs.isEmpty():
        print 'Failed to find any messages in DB'
        raise Exception('Failed to find any messages in DB')

    if msgs.size() < count:
        print 'Warning, did not find all messages expected'

    return msgs
开发者ID:piyush76,项目名称:EMS,代码行数:31,代码来源:testUtils.py

示例2: findMessages

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
def findMessages(mc,custid,count):
    print 'findMessages() find ',count
    amsm = mc.getActiveMailboxStoreManager()
    ids = HashSet()
    msgs = HashSet()
    retries = 30
    while msgs.size() < count and retries > 0:
        for p in mc.getPartitionManager().listPartitions():
            if p.isReadOnly():
                continue
            print 'searching for messages to be stored in',p
            tm = amsm.findMessages([SearchConstraint(IActiveMailboxStoreManager.PROP_CUST_ID, SearchConstraintOperator.CONSTRAINT_EQUALS,int(custid))],p)
            if tm.size() > 0:
                msgs.addAll(filter(lambda x : not ids.contains(x.getMessageId()),tm))
                ids.addAll(map(lambda x : x.getMessageId(), tm))

        if msgs.size() < count:
            time.sleep(10)
        retries = retries - 1

        print 'findMessages found',msgs.size(),'ids',ids.size()

    if msgs.isEmpty():
        print 'Failed to find any messages in DB'
        raise Exception('Failed to find any messages in DB')

    if msgs.size() < count:
        print 'Warning, did not find all messages expected'

    return msgs
开发者ID:piyush76,项目名称:EMS,代码行数:32,代码来源:testUtils.py

示例3: runJob

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
def runJob(cmdArray, hosts, sleepTime=60, maxWaits=60, interimResult=None):
    finished = HashSet()
    failures = HashSet()
    pb = ProcessBuilder(cmdArray)
    done = False
    # first wait is short in case job finishes quickly
    waitTime = 10
    while not done:
        p = pb.start()
        dataOut = DataOutputStream(p.getOutputStream())
        try:
            for host in hosts:
                dataOut.writeBytes(host + "\n")
        finally:
            dataOut.close()
        p.waitFor()
        (curFinished, curFailures) = processJobResults(p.getInputStream(), interimResult)
        finished.addAll(curFinished)
        failures.addAll(curFailures)
        done = finished.size() == len(hosts)

        if not done:
            maxWaits = maxWaits - 1
            done == maxWaits == 0

        if not done:
            time.sleep(waitTime)
            waitTime = sleepTime
    return failures
开发者ID:piyush76,项目名称:EMS,代码行数:31,代码来源:upgrade-solr.py

示例4: sliceSpaces

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def sliceSpaces( spaces):
     checked = HashSet()
     slices = []
     for i, space in enumerate(spaces):
         if not checked.contains(space):
             current = MeshMaker.createNewVerticalSlice(spaces, i)
             checked.addAll(current.tiles)
             slices.append(current)
     return slices
开发者ID:beltsonata,项目名称:PyPyPy,代码行数:11,代码来源:topography.py

示例5: getUniqueSrcIps

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
    def getUniqueSrcIps(self, protocol=6):
        uniqueIps = HashSet()
        srcAddrSqlBuilder = SelectSqlBuilder('Agg_V5', 'srcAddr as ip', distinct=1)
        srcAddrSqlBuilder.where('prot=%d' % protocol)
        srcIps = self._sqlClient.execute(srcAddrSqlBuilder)
        if srcIps:
            uniqueIps.addAll(Arrays.asList([ipEntry.ip for ipEntry in srcIps]))

        return uniqueIps.toArray()
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:11,代码来源:Network_Connectivity_Data_Analyzer.py

示例6: getVarsInLiveConjuncts

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def getVarsInLiveConjuncts(cls, rule, constantSentenceForms):
     """ generated source for method getVarsInLiveConjuncts """
     result = HashSet()
     for literal in rule.getBody():
         if isinstance(literal, (GdlRelation, )):
             if not SentenceModelUtils.inSentenceFormGroup(literal, constantSentenceForms):
                 result.addAll(GdlUtils.getVariables(literal))
         elif isinstance(literal, (GdlNot, )):
             if not SentenceModelUtils.inSentenceFormGroup(inner, constantSentenceForms):
                 result.addAll(GdlUtils.getVariables(literal))
     return result
开发者ID:hobson,项目名称:ggpy,代码行数:13,代码来源:OptimizingPropNetFactory.py

示例7: applyCondensation

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def applyCondensation(cls, condensationSet, rule, sentenceNameSource):
     """ generated source for method applyCondensation """
     varsInCondensationSet = HashSet()
     for literal in condensationSet:
         varsInCondensationSet.addAll(GdlUtils.getVariables(literal))
     varsToKeep = HashSet()
     for literal in condensationSet:
         varsToKeep.addAll(GdlUtils.getVariables(literal))
     varsToKeep2 = HashSet()
     varsToKeep2.addAll(GdlUtils.getVariables(rule.getHead()))
     for literal in rule.getBody():
         if not condensationSet.contains(literal):
             varsToKeep2.addAll(GdlUtils.getVariables(literal))
     varsToKeep.retainAll(varsToKeep2)
     orderedVars = ArrayList(varsToKeep)
     condenserName = sentenceNameSource.getNameWithPrefix(rule.getHead().__name__)
     condenserHead = GdlSentence()
     if orderedVars.isEmpty():
         condenserHead = GdlPool.getProposition(condenserName)
     else:
         condenserHead = GdlPool.getRelation(condenserName, orderedVars)
     condenserBody = ArrayList(condensationSet)
     condenserRule = GdlPool.getRule(condenserHead, condenserBody)
     remainingLiterals = ArrayList()
     for literal in rule.getBody():
         if not condensationSet.contains(literal):
             remainingLiterals.add(literal)
     remainingLiterals.add(condenserHead)
     modifiedRule = GdlPool.getRule(rule.getHead(), remainingLiterals)
     newRules = ArrayList(2)
     newRules.add(condenserRule)
     newRules.add(modifiedRule)
     return newRules
开发者ID:hobson,项目名称:ggpy,代码行数:35,代码来源:CondensationIsolator.py

示例8: findAllInstancesOf_1

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def findAllInstancesOf_1(self, var, gdl, loc):
     """ generated source for method findAllInstancesOf_1 """
     if not self.domains.containsKey(loc):
         self.domains.put(loc, self.Domain(loc))
     rval = HashSet()
     if isinstance(gdl, (GdlRelation, )):
         while i < relation.arity():
             parent.name = relation.__name__
             parent.idx = i
             rval.addAll(self.findAllInstancesOf(var, relation.get(i), parent))
             i += 1
     elif isinstance(gdl, (GdlDistinct, )):
         #           GdlDistinct distinct = (GdlDistinct)gdl;
         # Negative context, ignore it for now
     elif isinstance(gdl, (GdlNot, )):
         #           GdlNot not = (GdlNot)gdl;
         # Negative context, ignore it for now
     elif isinstance(gdl, (GdlOr, )):
         # TODO: check that this is right, I think it may not be
         while i < or_.arity():
             pass
             i += 1
     elif isinstance(gdl, (GdlProposition, )):
         #           GdlProposition prop = (GdlProposition)gdl;
         # I think these can safely be ignored, they have no body
     elif isinstance(gdl, (GdlConstant, )):
         #           GdlConstant constant = (GdlConstant)gdl;
         # Just a constant
     elif isinstance(gdl, (GdlFunction, )):
         while i < func.arity():
             parent.name = func.__name__
             parent.idx = i
             rval.addAll(self.findAllInstancesOf(var, func.get(i), parent))
             i += 1
     elif isinstance(gdl, (GdlVariable, )):
         # This is the interesting one
         if variable == var:
             # Found what we're looking for (base case of recursion)
             if loc == None:
                 raise RuntimeException("Parent missing for a variable.")
             rval.add(self.domains.get(loc))
     elif isinstance(gdl, (GdlRule, )):
         raise RuntimeException("Shouldn't nest rules.")
     return rval
开发者ID:hobson,项目名称:ggpy,代码行数:46,代码来源:PropNetAnnotater.py

示例9: findSatisfyingInstantiations_0

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def findSatisfyingInstantiations_0(self, conditions, idx, instantiation):
     """ generated source for method findSatisfyingInstantiations_0 """
     rval = HashSet()
     if idx == len(conditions):
         rval.add(instantiation)
         return rval
     cond = conditions.get(idx)
     dom = cond.dom
     assignments = None
     i = 0
     while i < len(cond.template):
         if isinstance(t, (GdlVariable, )):
             if instantiation.containsKey(v):
                 c = instantiation.get(v)
         elif isinstance(t, (GdlConstant, )):
             c = t
         if c != None:
             if assignments == None:
                 assignments = self.Assignments()
                 if len(dom.indices) > i:
                     if index.containsKey(c):
                         assignments.addAll(index.get(c))
             else:
                 if len(dom.indices) > i:
                     if index.containsKey(c):
                         assignments.retainAll(index.get(c))
                 else:
                     assignments.clear()
         i += 1
     if assignments == None:
         assignments = dom.assignments
     for a in assignments:
         while i < len(a):
             if isinstance(t, (GdlVariable, )):
                 if not instantiation.containsKey(var):
                     newInstantiation.put(var, a.get(i))
             i += 1
         rval.addAll(self.findSatisfyingInstantiations(conditions, idx + 1, newInstantiation))
     return rval
开发者ID:hobson,项目名称:ggpy,代码行数:41,代码来源:PropNetFlattener.py

示例10: search

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
def search(metaclasses, regexp, options):
  print "Searching ..."
  rawResults = HashSet()
  session = Modelio.getInstance().getModelingSession()
  
  #--- (1) Add all instances of selected metaclasses 
  for metaclass in metaclasses:
    print "  searching for instance of metaclass ",metaclass.getSimpleName()," ... ",
    metaclassInstances = session.findByClass(metaclass)
    print unicode(len(metaclassInstances)),"elements found"
    rawResults.addAll(metaclassInstances)
  # remove predefined types
  predefTypes = Modelio.getInstance().getModelingSession().getModel().getUmlTypes().getBOOLEAN().getOwner()
  rawResults.remove(predefTypes)
  rawResults.remove(predefTypes.getOwner())
  print "  ==>",unicode(len(rawResults)),"elements found (primitive types excluded)"
  
  #--- (2) Check for name matching
  filteredResults = []
  try:
    if options[0] == 1:
      p = Pattern.compile(regexp)
      for result in rawResults:
        name = result.getName()
        if (p.matcher(name).matches()):
          filteredResults.append(result)
    else:
      for result in rawResults:
        if result.getName().find(regexp) != -1:
          filteredResults.append(result)
  except PatternSyntaxException:
    messageBox("The entered regular expression: '"+regexp+"' has a syntax error.")
  except IllegalArgumentException:
    messageBox("Illegal Argument Exception.")
  print "  "+unicode(len(filteredResults))+" elements selected after name filtering"
  
  #--- (3) sort results by name
  filteredResults.sort(key=lambda x:x.getName())
  return filteredResults
开发者ID:escribis,项目名称:macros,代码行数:41,代码来源:AdvancedSearch.py

示例11: findAllInstancesOf

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
 def findAllInstancesOf(self, var, RHS):
     """ generated source for method findAllInstancesOf """
     rval = HashSet()
     for literal in RHS:
         rval.addAll(self.findAllInstancesOf(var, literal))
     return rval
开发者ID:hobson,项目名称:ggpy,代码行数:8,代码来源:PropNetAnnotater.py

示例12: GameFlow

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import addAll [as 别名]
class GameFlow(object):
    """ generated source for class GameFlow """
    INIT = GdlPool.getConstant("init")
    TRUE = GdlPool.getConstant("true")
    NEXT = GdlPool.getConstant("next")
    turnAfterLast = int()

    # We end with a loop
    sentencesTrueByTurn = ArrayList()

    # The non-constant ones
    formsControlledByFlow = Set()
    constantForms = Set()
    constantChecker = ConstantChecker()

    def __init__(self, description):
        """ generated source for method __init__ """
        description = GdlCleaner.run(description)
        description = DeORer.run(description)
        description = VariableConstrainer.replaceFunctionValuedVariables(description)
        # First we use a sentence model to get the relevant sentence forms
        model = SentenceDomainModelFactory.createWithCartesianDomains(description)
        self.formsControlledByFlow = HashSet()
        self.formsControlledByFlow.addAll(model.getIndependentSentenceForms())
        self.formsControlledByFlow.removeAll(model.getConstantSentenceForms())
        self.constantForms = model.getConstantSentenceForms()
        self.constantChecker = ConstantCheckerFactory.createWithForwardChaining(model)
        # Figure out which of these sentences are true at each stage
        solveTurns(model)

    def solveTurns(self, model):
        """ generated source for method solveTurns """
        # Before we can do anything else, we need a topological ordering on our forms
        ordering = getTopologicalOrdering(model.getIndependentSentenceForms(), model.getDependencyGraph())
        ordering.retainAll(self.formsControlledByFlow)
        # Let's add function info to the consideration...
        functionInfoMap = HashMap()
        for form in constantForms:
            functionInfoMap.put(form, FunctionInfoImpl.create(form, self.constantChecker))
        # First we set the "true" values, then we get the forms controlled by the flow...
        # Use "init" values
        trueFlowSentences = HashSet()
        for form in constantForms:
            if form.__name__ == self.INIT:
                for initSentence in constantChecker.getTrueSentences(form):
                    trueFlowSentences.add(trueSentence)
        # Go through ordering, adding to trueFlowSentences
        addSentenceForms(ordering, trueFlowSentences, model, functionInfoMap)
        self.sentencesTrueByTurn.add(trueFlowSentences)
        while True:
            # Now we use the "next" values from the previous turn
            trueFlowSentences = HashSet()
            for sentence in sentencesPreviouslyTrue:
                if sentence.__name__ == self.NEXT:
                    trueFlowSentences.add(trueSentence)
            addSentenceForms(ordering, trueFlowSentences, model, functionInfoMap)
            # Test if this turn's flow is the same as an earlier one
            while i < len(self.sentencesTrueByTurn):
                if prevSet == trueFlowSentences:
                    # Complete the loop
                    self.turnAfterLast = i
                    break
                i += 1
            self.sentencesTrueByTurn.add(trueFlowSentences)

    @SuppressWarnings("unchecked")
    def addSentenceForms(self, ordering, trueFlowSentences, model, functionInfoMap):
        """ generated source for method addSentenceForms """
        for curForm in ordering:
            # Check against trueFlowSentences, add to trueFlowSentences
            # or check against constantForms if necessary
            # Use basic Assignments class, of course
            for alwaysTrueSentences in model.getSentencesListedAsTrue(curForm):
                trueFlowSentences.add(alwaysTrueSentences)
            for rule in model.getRules(curForm):
                while asnItr.hasNext():
                    if trueFlowSentences.contains(transformedHead):
                        asnItr.changeOneInNext(varsInHead, assignment)
                    # Go through the conjuncts
                    for literal in rule.getBody():
                        if isinstance(literal, (GdlSentence, )):
                            if curForm.matches(literal):
                                raise RuntimeException("Haven't implemented recursion in the game flow")
                            if self.constantForms.contains(conjForm):
                                if not self.constantChecker.isTrueConstant(transformed):
                                    isGoodAssignment = False
                                    asnItr.changeOneInNext(GdlUtils.getVariables(literal), assignment)
                            else:
                                if not trueFlowSentences.contains(transformed):
                                    # False sentence
                                    isGoodAssignment = False
                                    asnItr.changeOneInNext(GdlUtils.getVariables(literal), assignment)
                        elif isinstance(literal, (GdlNot, )):
                            if self.constantForms.contains(conjForm):
                                if self.constantChecker.isTrueConstant(transformed):
                                    isGoodAssignment = False
                                    asnItr.changeOneInNext(GdlUtils.getVariables(literal), assignment)
                            else:
                                if trueFlowSentences.contains(transformed):
                                    # False sentence
#.........这里部分代码省略.........
开发者ID:hobson,项目名称:ggpy,代码行数:103,代码来源:GameFlow.py


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