p2

凸包

房东的猫 提交于 2019-11-30 18:41:20
转自 https://www.cnblogs.com/wuwangchuxin0924/p/6223152.html 了解凸包及Graham扫描法 问题描述:二位平面内,给定n个散乱的点,求一个最小凸多边形(凸包),使得n个点都不在凸多边形外。 问题的解决用到Graham算法: 算法步骤:   1.取y坐标最小的一点,作为p0,显然p0一定在凸包上。   2.将p0作为坐标系原点,其他点按极角从小到大排序,从p1开始编号。   3.从小到大遍历所有点:显然[p0, p1] 在凸包中   4.连接p1, p2的时候需要判断:p0->p1 叉乘 p1->p2 是否大于0:     > 0 p1->p2 在 p0->p1 夹角小于π,物理意义:p1->p2 在 p0->p1的左边,满足凸多边形定义。     = 0 p1->p2 与 p0->p1 共线,同向满足,相反不满足。     < 0 p1->p2 在 p0->p1 夹角大于π,不满足。   5.连接p2, p3 向量p2->p3在p1->p2左边,满足定义,当连接p3, p4的时候,发现不满足定义了,此时要放弃p3, 从p2开始回溯,找到第一个满足要求的点。   6.以此类推,知道回到p0点。 Graham scan 正确性: 令散点的数量为k,散点(p0 ~ pk – 1)已经按照极角排序。 当k=3时,显然,p0-

How to download large sized Files (size > 50MB) in java

馋奶兔 提交于 2019-11-30 10:20:59
I'm downloading files from a remote location, and the download is complete for smaller sized files and in-complete for large sized files (>10 MB). Here is my code that i have used for downloading files from remote server . File dstFile = null; // check the directory for existence. String dstFolder = LOCAL_FILE.substring(0,LOCAL_FILE.lastIndexOf(File.separator)); if(!(dstFolder.endsWith(File.separator) || dstFolder.endsWith("/"))) dstFolder += File.separator; // Creates the destination folder if doesn't not exists dstFile = new File(dstFolder); if (!dstFile.exists()) { dstFile.mkdirs(); } try {

Running P2 Ant tasks outside Eclipse

给你一囗甜甜゛ 提交于 2019-11-30 04:11:59
I got ant script running fine inside Eclipse Here is a piece of it : <p2.composite.repository failOnExists="true"> <repository location="file:/${basedir}/compRepo" name="Repository description goes here" /> <add> <repository location="http://url/Eclipse/repo/Galileo-3.5.1/" /> <repository location="http://another-url/Java/repo/4.0/" /> <repository location="${diag.location}" /> </add> </p2.composite.repository> But I would like Hudson CI server to be able to run it, but, no matter all the jars I put in ANT_HOME/lib I can't get this task to run in a simple command line ant... I got stuck with

Can Eclipse 3.5 discover all bundles in the plugins dir?

六眼飞鱼酱① 提交于 2019-11-30 03:13:31
问题 Simple usecase : assemble an Eclipse product using simple scripts, just dumping bundles into the plugins dir . This used to work with 3.3 - with 3.5 it's broken: my application doesn't start as the app plugin is not found. Question : what's the easiest way to fix that? This seems to be the only pain in the whole upgrade process for me. Attempts : I guess this is a no-no for P2: it maintains the bundles.info file instead, which is probably very smart.. a bit too smart for me. Some ideas I had:

合并两个有序数组

余生颓废 提交于 2019-11-30 01:08:21
题目描述: 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。 说明: 初始化 nums1 和 nums2 的元素数量分别为 m 和 n。 你可以假设 nums1 有足够的空间(空间大小大于或等于 m + n)来保存 nums2 中的元素。 示例: 输入: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2,5,6], n = 3 输出: [1,2,2,3,5,6] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/merge-sorted-array 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 方法一:直接合并排序,时间复杂度较差。 class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. """ nums1[:] = sorted(nums1[:m] + nums2) 方法二: class Solution: def merge(self, nums1:

在单向链表中如何快速查到倒数第n个节点 这简直是一种神奇的思路!!!!leetcode 删除倒数第n个节点

放肆的年华 提交于 2019-11-29 20:44:34
在单向链表中如何快速查到倒数第n个节点? 操作方法和步骤: (1)定义2个指针p1,p2。 (2)使用循环让p2指向顺数第n个节点,同时p1指向第头结点; (3)然后,p1和p2同时移动,直到p2指向NULL,此时p1应该指向倒数第n个节点。 19. Remove Nth Node From End of List 方法一: <span style="font-family:SimHei;font-size:18px;">/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { int k=0; ListNode *p=head; while(p) { k++; p=p->next; } if(head==NULL || head->next==NULL) return NULL; else if(head->next->next==NULL) { if(n==1) head->next=NULL; if(n=

How to download large sized Files (size > 50MB) in java

冷暖自知 提交于 2019-11-29 15:38:24
问题 I'm downloading files from a remote location, and the download is complete for smaller sized files and in-complete for large sized files (>10 MB). Here is my code that i have used for downloading files from remote server . File dstFile = null; // check the directory for existence. String dstFolder = LOCAL_FILE.substring(0,LOCAL_FILE.lastIndexOf(File.separator)); if(!(dstFolder.endsWith(File.separator) || dstFolder.endsWith("/"))) dstFolder += File.separator; // Creates the destination folder

Adding update site URLs to find third-party dependencies during install

别来无恙 提交于 2019-11-29 02:00:59
I have an Eclipse feature which when installing on Helios requires an additional update-site URL to be present in order to find certain dependencies. Is it possible to automatically add such an URL so that the user doesn't have to do it manually? Or is it considered bad practice to do so? I've tried to add addRepository action to the p2.inf file of the feature, but it is not executed. The only way I have found is to add repository references into content.jar/content.xml by hand. For example, to add EMF update site into the list of available update sites one can add the following code to

Combine/aggregate eclipse p2 repositories / extendable p2 repository

守給你的承諾、 提交于 2019-11-28 19:45:12
With maven/tycho build for Nodeclipse Eclipse plugin there is new p2 repository every release. Release is done on Bintray that does not allow to update files. So every version goes in its folder. BaseFolder BaseFolder/VersionFolder1 BaseFolder/VersionFolder2 BaseFolder/VersionFolder3 Is it possible to have BaseFolder prepared once as extendable p2 repository, and VersionFolderN added later? So that there would be only one URL for updates and Eclipse platform could discover updates in the repository. What you are looking for is a composite p2 repository. You'll just need the following two files

第十一章、菱形继承问题

风格不统一 提交于 2019-11-28 18:20:55
目录 第十一章、菱形继承问题 一、菱形继承问题 第十一章、菱形继承问题 一、菱形继承问题 引用:属性查找顺序中 对象自身——》子类——》父类(多继承)——》报错 中间父类多继承的查找顺序问题 而对经典类和新式类来说,属性的查找顺序是不同的。现在我们分别看一下经典类和新式类两种不同的表现: 经典类 #! /usr/bin/python # -*- coding:utf-8 -*- class P1(): def foo(self): print 'p1-foo' class P2(): def foo(self): print 'p2-foo' def bar(self): print 'p2-bar' class C1(P1,P2): pass class C2(P1,P2): def bar(self): print 'C2-bar' class D(C1,C2): pass if __name__ =='__main__': d=D() d.foo() d.bar() ​ 执行的结果: ​ p1-foo p2-bar 把代码实例画了图 从上面经典类的输出结果来看, 实例d调用foo()时,搜索顺序是 D => C1 => P1, 实例d调用bar()时,搜索顺序是 D => C1 => P1 => P2 总结:经典类的搜索方式是按照“从左至右,深度优先”的方式去查找属性