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


Python Arrays.sort方法代码示例

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


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

示例1: setActiveChannel

# 需要导入模块: from java.util import Arrays [as 别名]
# 或者: from java.util.Arrays import sort [as 别名]
 def setActiveChannel(self, channel):
     self.channel = channel
     # convert from List to Array
     items = self.channel.getItems().toArray()
     # sort news items
     Arrays.sort(items, ItemComparator(1))
     self.items = items
     self.fireTableDataChanged()
开发者ID:optivo-org,项目名称:informa-0.7.0-optivo,代码行数:10,代码来源:minigui.py

示例2: __queryNewestRefTime

# 需要导入模块: from java.util import Arrays [as 别名]
# 或者: from java.util.Arrays import sort [as 别名]
 def __queryNewestRefTime(self):
     from com.raytheon.uf.viz.core.catalog import CatalogQuery
     from java.util import Arrays
     from com.raytheon.uf.common.time import DataTime                 
     results = CatalogQuery.performQuery('dataTime.refTime', self._buildConstraints(None))
     Arrays.sort(results)
     if len(results) == 0:
         if self.site:
             raise NoDataException.NoDataException("No data available for site " + self.site)
         else:
             raise NoDataException.NoDataException("No data available")
     dt = DataTime(results[len(results)-1])        
     return dt.getRefTime().getTime() / 1000
开发者ID:KeithLatteri,项目名称:awips2,代码行数:15,代码来源:PointDataRetrieve.py

示例3: run

# 需要导入模块: from java.util import Arrays [as 别名]
# 或者: from java.util.Arrays import sort [as 别名]
def run(title):
    gd = GenericDialog("Record Window")
    gd.addMessage("Maximum number of frames to record.\nZero means infinite, interrupt with ESC key.")
    gd.addNumericField("Max. frames:", 50, 0)
    gd.addNumericField("Milisecond interval:", 300, 0)
    gd.addSlider("Start in (seconds):", 0, 20, 5)
    frames = []
    titles = []
    for f in Frame.getFrames():
        if f.isEnabled() and f.isVisible():
            frames.append(f)
            titles.append(f.getTitle())
    gd.addChoice("Window:", titles, titles[0])
    gd.addCheckbox("To file", False)
    gd.showDialog()
    if gd.wasCanceled():
        return
    n_frames = int(gd.getNextNumber())
    interval = gd.getNextNumber() / 1000.0  # in seconds
    frame = frames[gd.getNextChoiceIndex()]
    delay = int(gd.getNextNumber())
    tofile = gd.getNextBoolean()

    dir = None
    if tofile:
        dc = DirectoryChooser("Directory to store image frames")
        dir = dc.getDirectory()
        if dir is None:
            return  # dialog canceled

    snaps = []
    borders = None
    executors = Executors.newFixedThreadPool(1)
    try:
        while delay > 0:
            IJ.showStatus("Starting in " + str(delay) + "s.")
            time.sleep(1)  # one second
            delay -= 1

        IJ.showStatus("Capturing frame borders...")
        bounds = frame.getBounds()
        robot = Robot()
        frame.toFront()
        time.sleep(0.5)  # half a second
        borders = robot.createScreenCapture(bounds)

        IJ.showStatus("Recording " + frame.getTitle())

        # Set box to the inside borders of the frame
        insets = frame.getInsets()
        box = bounds.clone()
        box.x = insets.left
        box.y = insets.top
        box.width -= insets.left + insets.right
        box.height -= insets.top + insets.bottom

        start = System.currentTimeMillis() / 1000.0  # in seconds
        last = start
        intervals = []
        real_interval = 0
        i = 1
        fus = None
        if tofile:
            fus = []

            # 0 n_frames means continuous acquisition
        while 0 == n_frames or (len(snaps) < n_frames and last - start < n_frames * interval):
            now = System.currentTimeMillis() / 1000.0  # in seconds
            real_interval = now - last
            if real_interval >= interval:
                last = now
                img = snapshot(frame, box)
                if tofile:
                    fus.append(executors.submit(Saver(i, dir, bounds, borders, img, insets)))  # will flush img
                    i += 1
                else:
                    snaps.append(img)
                intervals.append(real_interval)
            else:
                time.sleep(interval / 5)
                # interrupt capturing:
            if IJ.escapePressed():
                IJ.showStatus("Recording user-interrupted")
                break

                # debug:
                # print "insets:", insets
                # print "bounds:", bounds
                # print "box:", box
                # print "snap dimensions:", snaps[0].getWidth(), snaps[0].getHeight()

                # Create stack
        stack = None
        if tofile:
            for fu in snaps:
                fu.get()  # wait on all
            stack = VirtualStack(bounds.width, bounds.height, None, dir)
            files = File(dir).list(TifFilter())
            Arrays.sort(files)
            for f in files:
#.........这里部分代码省略.........
开发者ID:Mverp,项目名称:fiji,代码行数:103,代码来源:Record_Window.py

示例4: main

# 需要导入模块: from java.util import Arrays [as 别名]
# 或者: from java.util.Arrays import sort [as 别名]
     # Unit tests the <tt>Interval1D</tt> data type.
     #/
    def main(String[] args):
        Interval1D[] intervals = new Interval1D[4]
        intervals[0] = new Interval1D(15.0, 33.0)
        intervals[1] = new Interval1D(45.0, 60.0)
        intervals[2] = new Interval1D(20.0, 70.0)
        intervals[3] = new Interval1D(46.0, 55.0)

        prt.write("Unsorted")
        for (int i = 0; i < len(intervals); i += 1)
            prt.write(intervals[i])
        prt.write()
        
        prt.write("Sort by left endpoint")
        Arrays.sort(intervals, Interval1D.LEFT_ENDPOINT_ORDER)
        for (int i = 0; i < len(intervals); i += 1)
            prt.write(intervals[i])
        prt.write()

        prt.write("Sort by right endpoint")
        Arrays.sort(intervals, Interval1D.RIGHT_ENDPOINT_ORDER)
        for (int i = 0; i < len(intervals); i += 1)
            prt.write(intervals[i])
        prt.write()

        prt.write("Sort by length")
        Arrays.sort(intervals, Interval1D.LENGTH_ORDER)
        for (int i = 0; i < len(intervals); i += 1)
            prt.write(intervals[i])
        prt.write()
开发者ID:raincoatrun,项目名称:PrincetonAlgorithms,代码行数:33,代码来源:Interval1D.py


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