zoukankan      html  css  js  c++  java
  • List 通过 Collections.binarySearch 进行记录筛选

    1.

    Collections.sort(list, new Comparator<TreeDto>() {
        @Override
        public int compare(TreeDto a2, TreeDto b2) {
            return a2.getId().compareTo(b2.getId());
        }
    });
    
    Collections.binarySearch(list,new TreeDto(null,null,Integer.valueOf(paramId),null,null,null,null,null), new Comparator<TreeDto>() {
        @Override
        public int compare(TreeDto o1, TreeDto o2) {
            // TODO Auto-generated method stub
            if (o1.getPid() != null && o2.getPid() != null) {
                return o1.getPid().compareTo(o2.getPid());
            }else if (o1.getPid() == null && o2.getPid() == null) {
                return 0;
            }
            return -1;
        }
    });
  • 相关阅读:
    python
    python
    python
    python
    python
    python
    python
    python
    人生苦短,我用python,为什么选择python,python简介
    Mysql-查询
  • 原文地址:https://www.cnblogs.com/rinack/p/7473080.html
Copyright © 2011-2022 走看看