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


Python Collections.emptySet方法代码示例

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


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

示例1: __init__

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import emptySet [as 别名]
  def __init__(self):
    self.speed = 5;
    self.speedZoom = .01;
    
    self.m_systemID = HashedString("RTSCameraSystem")

    #private final static List<HashedString> usedComponents;
    #private final static List<HashedString> optionalComponents;
    #private final static Set<HashedString> writeToComponents;
    #private final static Set<HashedString> otherComponents;
    #private final static Set<HashedString> usedInterfaces;
    #private final static Set<HashedString> writeToInterfaces;
  
  
    components = ArrayList()
    components.add(RTSCameraComponent.getComponentStaticType())
    self.m_usedComponents = Collections.unmodifiableList(components)
    
    components = ArrayList()
    components.add(CameraComponent.getComponentStaticType())
    self.m_optionalComponents = Collections.unmodifiableList(components)
    
    writes =  HashSet()
    writes.add(RTSCameraComponent.getComponentStaticType())
    writes.add(CameraComponent.getComponentStaticType())
    
    self.m_writeToComponents = Collections.unmodifiableSet(writes)
    
    self.m_otherComponents = Collections.emptySet()

    interfaces = HashSet()
    interfaces.add(SystemManager.inputInteface)
    self.m_usedInterfaces = Collections.unmodifiableSet(interfaces)
    self.m_writeToInterfaces = Collections.unmodifiableSet(HashSet(self.m_usedInterfaces))
开发者ID:Atridas,项目名称:Antagonista,代码行数:36,代码来源:RTSCameraSystem.py

示例2: getFunctionAddedChildren

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import emptySet [as 别名]
 def getFunctionAddedChildren(self, analyticFunctionOrdering):
     """ generated source for method getFunctionAddedChildren """
     # We can't just add those functions that
     # are "ready" to be added. We should be adding all those variables
     # "leading up to" the functions and then applying the functions.
     # We can even take this one step further by only adding one child
     # per remaining constant function; we choose as our function output the
     # variable that is a candidate for functionhood that has the
     # largest domain, or one that is tied for largest.
     # New criterion: Must also NOT be in preassignment.
     children = ArrayList()
     # It would be really nice here to just analytically choose
     # the set of functions we're going to use.
     # Here's one approach for doing that:
     # For each variable, get a list of the functions that could
     # potentially produce it.
     # For all the variables with no functions, add them.
     # Then repeatedly find the function with the fewest
     # number of additional variables (hopefully 0!) needed to
     # specify it and add it as a function.
     # The goal here is not to be optimal, but to be efficient!
     # Certain games (e.g. Pentago) break the old complete search method!
     # TODO: Eventual possible optimization here:
     # If something is dependent on a connected component that it is
     # not part of, wait until the connected component is resolved
     # (or something like that...)
     if analyticFunctionOrdering and len(self.functionalSentencesInfo) > 8:
         # For each variable, a list of functions
         # (refer to functions by their indices)
         # and the set of outstanding vars they depend on...
         # We start by adding to the varOrdering the vars not produced by functions
         # First, we have to find them
         while i < len(self.functionalSentencesInfo):
             for producibleVar in producibleVars:
                 if not functionsProducingVars.containsKey(producibleVar):
                     functionsProducingVars.put(producibleVar, HashSet())
                 functionsProducingVars.get(producibleVar).add(i)
             i += 1
         # Non-producible vars get iterated over before we start
         # deciding which functions to add
         for var in varsToAssign:
             if not self.varOrdering.contains(var):
                 if not functionsProducingVars.containsKey(var):
                     # Add var to the ordering
                     self.varOrdering.add(var)
                     self.functionalConjunctIndices.add(-1)
                     self.varSources.add(-1)
         # Map is from potential set of dependencies to function indices
         # Create this map...
         while i < len(self.functionalSentencesInfo):
             # Variables already in varOrdering don't go in dependents list
             producibleVars.removeAll(self.varOrdering)
             allVars.removeAll(self.varOrdering)
             for producibleVar in producibleVars:
                 dependencies.addAll(allVars)
                 dependencies.remove(producibleVar)
                 if not functionsHavingDependencies.containsKey(dependencies):
                     functionsHavingDependencies.put(dependencies, HashSet())
                 functionsHavingDependencies.get(dependencies).add(i)
             i += 1
         # Now, we can keep creating functions to generate the remaining variables
         while len(self.varOrdering) < len(self.varsToAssign):
             if functionsHavingDependencies.isEmpty():
                 raise RuntimeException("We should not run out of functions we could use")
             # Find the smallest set of dependencies
             if functionsHavingDependencies.containsKey(Collections.emptySet()):
                 dependencySetToUse = Collections.emptySet()
             else:
                 for dependencySet in functionsHavingDependencies.keySet():
                     if len(dependencySet) < smallestSize:
                         smallestSize = len(dependencySet)
                         dependencySetToUse = dependencySet
             # See if any of the functions are applicable
             for function_ in functions:
                 producibleVars.removeAll(dependencySetToUse)
                 producibleVars.removeAll(self.varOrdering)
                 if not producibleVars.isEmpty():
                     functionToUse = function_
                     varProduced = producibleVars.iterator().next()
                     break
             if functionToUse == -1:
                 # None of these functions were actually useful now?
                 # Dump the dependency set
                 functionsHavingDependencies.remove(dependencySetToUse)
             else:
                 # Apply the function
                 # 1) Add the remaining dependencies as iterated variables
                 for var in dependencySetToUse:
                     self.varOrdering.add(var)
                     self.functionalConjunctIndices.add(-1)
                     self.varSources.add(-1)
                 # 2) Add the function's produced variable (varProduced)
                 self.varOrdering.add(varProduced)
                 self.functionalConjunctIndices.add(functionToUse)
                 self.varSources.add(-1)
                 # 3) Remove all vars added this way from all dependency sets
                 addedVars.addAll(dependencySetToUse)
                 addedVars.add(varProduced)
                 # Tricky, because we have to merge sets
                 # Easier to use a new map
#.........这里部分代码省略.........
开发者ID:hobson,项目名称:ggpy,代码行数:103,代码来源:IterationOrderCandidate.py


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