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


Python HashSet.retainAll方法代码示例

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


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

示例1: applyCondensation

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import retainAll [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

示例2: updateDomains

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import retainAll [as 别名]
 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,代码行数:32,代码来源:PropNetAnnotater.py

示例3: getTurnsConjunctsArePossible

# 需要导入模块: from java.util import HashSet [as 别名]
# 或者: from java.util.HashSet import retainAll [as 别名]
 def getTurnsConjunctsArePossible(self, body):
     """ generated source for method getTurnsConjunctsArePossible """
     # We want to identify the conjuncts that are used by the
     # game flow.
     relevantLiterals = ArrayList()
     for literal in body:
         if isinstance(literal, (GdlSentence, )):
             if SentenceModelUtils.inSentenceFormGroup(sentence, self.formsControlledByFlow):
                 relevantLiterals.add(literal)
         elif isinstance(literal, (GdlNot, )):
             if SentenceModelUtils.inSentenceFormGroup(innerSentence, self.formsControlledByFlow):
                 relevantLiterals.add(literal)
     # If none are related to the game flow, then that's it. It can
     # happen on any turn.
     # if(relevantLiterals.isEmpty())
     # return getCompleteTurnSet();
     turnsPossible = HashSet(getCompleteTurnSet())
     # For each of the relevant literals, we need to see if there are assignments
     # such that
     for literal in relevantLiterals:
         if isinstance(literal, (GdlSentence, )):
             while t < self.getNumTurns():
                 if self.sentencesTrueByTurn.get(t).contains(literal):
                     turns.add(t)
                 else:
                     for s in sentencesTrueByTurn.get(t):
                         # Could be true if there's an assignment
                         if None != GdlUtils.getAssignmentMakingLeftIntoRight(literal, s):
                             turns.add(t)
                             break
                 t += 1
         elif isinstance(literal, (GdlNot, )):
             while t < self.getNumTurns():
                 if not self.sentencesTrueByTurn.get(t).contains(internal):
                     turns.add(t)
                 else:
                     for s in sentencesTrueByTurn.get(t):
                         if None != GdlUtils.getAssignmentMakingLeftIntoRight(internal, s):
                             turns.add(t)
                             break
                 t += 1
         # Accumulate turns
         # Note that all relevant conjuncts must be true, so this
         # is an intersection of when the individual conjuncts
         # could be true.
         turnsPossible.retainAll(turns)
     return turnsPossible
开发者ID:hobson,项目名称:ggpy,代码行数:49,代码来源:GameFlow.py


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