當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。