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


Python Collections.shuffle方法代码示例

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


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

示例1: append_to_errors

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import shuffle [as 别名]
    def append_to_errors(self, errorsList, check):
        """Clean errors list from duplicate errors and ids that must be
           ignored
        """
        if errorsList[0][0] == "":
            #osmId == "", this tool doesn't give id of OSM objects
            check.errors = [Error(check, e) for e in errorsList]
        else:
            if check.ignoreIds != []:
                #remove OSM objects that the user wants to ignore
                check.errors = [Error(check, e) for e in errorsList if e[0] not in check.ignoreIds]

                #remove duplicate ids
                #check.errors = dict((e.osmId, e) for e in check.errors).values()
            else:
                #copy all errors and remove duplicate ids
                #check.errors = dict((e[0], Error(e)) for e in errorsList).values()
                check.errors = [Error(check, e) for e in errorsList]

            #Remove from the list of errors those that have been reviewed yet
            #while clicking the "Next" button
            check.errors = [e for e in check.errors if e.osmId not in check.reviewedIds]

        #print "\n- errors of selected check in current zone:", [e.osmId for e in check.errors]

        #Randomize the errors so that different users don't start
        #correcting the same errors
        Collections.shuffle(check.errors)

        #Filter errors in favourite zone
        if self.app.favouriteZoneStatus and self.app.favZone.zType != "rectangle":
            #not rectangular favourite area, use jts
            from com.vividsolutions.jts.geom import Coordinate, GeometryFactory
            polygon = self.app.favZone.wktGeom
            errorsInPolygon = []
            for error in check.errors:
                (lat, lon) = error.coords
                point = GeometryFactory().createPoint(Coordinate(lon, lat))
                if polygon.contains(point):
                    if error not in errorsInPolygon:
                        errorsInPolygon.append(error)
            check.errors = errorsInPolygon

        #Apply limits from preferences
        #max number of errors
        limits = []
        if self.app.maxErrorsNumber != "":
            limits.append(self.app.maxErrorsNumber)
        try:
            if self.tool.prefs["limit"] != "":
                limits.append(int(self.tool.prefs["limit"]))
        except:
            pass
        if limits != []:
            check.errors = check.errors[:min(limits)]

        #Reset index of current error
        check.currentErrorIndex = -1
        check.toDo = len(check.errors)
开发者ID:alex85k,项目名称:qat_script,代码行数:61,代码来源:download_and_parse.py

示例2: getRandomWord

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import shuffle [as 别名]
 def getRandomWord(self):
     """ generated source for method getRandomWord """
     if self.scrambledTokens.isEmpty():
         for word in WordList.words:
             self.scrambledTokens.add(word + self.scrambledPrefix)
         Collections.shuffle(self.scrambledTokens, self.random)
         self.scrambledPrefix += 1
     return self.scrambledTokens.pop()
开发者ID:hobson,项目名称:ggpy,代码行数:10,代码来源:MappingGdlScrambler.py

示例3: __init__

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import shuffle [as 别名]
 def __init__(self, theRandom):
     """ generated source for method __init__ """
     super(MappingGdlScrambler, self).__init__()
     self.random = theRandom
     self.scrambleMapping = HashMap()
     self.unscrambleMapping = HashMap()
     self.scrambledPrefix = 0
     self.scrambledTokens = Stack()
     for word in WordList.words:
         self.scrambledTokens.add(word)
     Collections.shuffle(self.scrambledTokens, self.random)
开发者ID:hobson,项目名称:ggpy,代码行数:13,代码来源:MappingGdlScrambler.py


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