comparator

    1热度

    2回答

    我正在尝试使用Collections.sort()对List<Point2D>点进行排序。我相信我正确设置了这个比较器。无论如何,这是抛出一个错误说:The method sort(List<T>, Comparator<? superT>) in the type Collections is not applicable for the arguments (List<Point2D>, ne

    1热度

    2回答

    我在寻找一个“动态比较器”,根据运行时参数给出比较结果。 这是一个比较器,根据它们到输入参数x的距离比较两个整数。 struct leq { bool operator()(const int a, const int b, const int x) { return abs(a-x) <= abs(b-x); } }; 希望用它来实现下列插入到含有一个整数

    0热度

    1回答

    我写这个的jsfiddle测试AngularJS比较,但比较不工作: my jsFiddle Comparator 看来,我的比较功能wiggleSort将不会被调用: <span data-ng-repeat="myItem in myArray | orderBy:'start':false:wiggleSort" 我做错了什么?

    1热度

    6回答

    假设我有以下的compareTo: public int compareTo(RandomClass o) { if (this.value() < o.value()) { return -1; } else if (this.value() > o.value()) { return 1; } else { return 0;

    3热度

    3回答

    首先,请让我明确一点,我受API设计的限制,所以请不要更改API,但是可以添加私有函数。 public class Point implements Comparable<Point> { public Point(int x, int y) // constructs the point (x, y) public void draw() // draws

    2热度

    2回答

    我正在学习Comparator接口来解决分数背包问题。行a和b中的两个数组表示3个值 - 权重对 - (60,20),(100,50),(120,30)。比较器应该根据v [i]/w [i]的比值对arr []进行排序。但是,下面的代码给了我奇怪的错误: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3

    1热度

    3回答

    我有一个字符串地图的字符串,我想排序地图根据他的价值为凯F,但我的代码没有这样做。请指教。 Map<String, String> h = null; Map<String, String> h1 = null; Map<String, String> h2 = null; listSummaryMap = new ArrayList<Map<String, Stri

    0热度

    3回答

    class IntegerComparator implements Comparator<Integer> { @Override public int compare(Integer o1, Integer o2) { if(o1 < o2) return 1; else if(o1 > o2) return -1; else

    -3热度

    1回答

    如何最小化使用java的比较器方法8 实际上,我通过包含工作日的工作日列表,其中包含我需要按日期升序和降序排列日期的工作日清单 我需要日期按升序 private List<WorkingDays> workingDaysDateSortDesc(List<WorkingDays> workingDays) { Collections.sort(workingDays.get(0).get

    0热度

    1回答

    好Day- 我的工作中,我已经指令来创建一个命名为void sortByAthleteNames()方法,该方法将执行以下任务的任务: 排序列表运动员用名字和姓氏对象。此方法调用在排序类中定义的类型的方法,使用AthleteNameComparator类的对象作为其第二个参数 排序类具有以下实现: public class Sorts { public static void sort