`
tanglei198577
  • 浏览: 59909 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

Tree set for sorting

 
阅读更多

code:

   Set<Pattern> sortedPatterns = new TreeSet<Pattern>();
   for(Pattern pattern : project.getPatterns()){
    sortedPatterns.add(pattern);
   }
   project.setPatterns(sortedPatterns);

 

Then the Pattern need to implements Comparable interface

then finished your method compareTo with your requirement is ok

here is the example:

 

	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		Pattern pp1 = (Pattern)o;
		Pattern pp2 = this;
		if(pp2.getType()==null || pp2.getType().equals("")){
			return -1;
		}
		if(pp1.getType()==null || pp1.getType().equals("")){
			return 1;
		}
		return (pp2.getId()).compareTo(pp1.getId());
	}

 

0
2
分享到:
评论

相关推荐

    Algorithms and Data Structures - Niklaus Wirth

    - **Polyphase Sort**: A variant of merge sort designed for external sorting. - **Distribution of Initial Runs**: Analysis of initial runs in sorting sequences. #### Recursive Algorithms **...

    华南理工大学计算机全英班算法设计实验

    Figure 2 The initial node and goal node for the tree search algorithm 4.Experimental Requirements 1)The template should be used for all kinds of data type, such as: integer, real, double, etc. in the...

    The Algorithm Design Manual (2rd Edition)

    4.3 Heapsort: Fast Sorting via Data Structures 4.4 War Story: Give me a Ticket on an Airplane 4.5 Mergesort: Sorting by Divide-and-Conquer 4.6 Quicksort: Sorting by Randomization 4.7 Distribution...

    Learning.JavaScript.Data.Structures.and.Algorithms.1783554878

    You will also gain an in-depth knowledge of how hash tables and set data structure function. After this, you will be taught what trees are, and how to use the binary tree and the binary search tree. ...

    testlink-1.9.3.tar

    You can have different set of test cases for each platform - XML export/import of test cases and platforms links - XML export of testplan contents - Private Test plans Test Specification - Test ...

    Computing and Combinatorics

    bicliques.- Fast Coupled Path Planning: From Pseudo-Polynomial to Polynomial.- Constant Time Approximation Scheme for Largest Well Predicted Subset.- On Sorting Permutations by Double-Cut-and-Joins.- ...

    SQLMemTable for Delphi / C++ Builder

    - Fast search by B-tree indexes. At the moment SQLMemTable is one of the fastest existing in-memory tables for Delphi and C++ Builder. - High-speed memory operations performance is achieved by means ...

    算法导论英文版

    8.l Lower bounds for sorting 165 8.2 Counting sort i68 8.3 Radix sort 170 8.4 Bucket sort 174 9 Medians and Order Statistics 183 9.1 Minimum and maximum 184 9.2 Selection in expected linear time 185 ...

    BobBuilder_app

    Theoretically a b+tree is O(N log k N) or log base k of N, now for the typical values of k which are above 200 for example the b+tree should outperform any binary tree because it will use less ...

    算法导论--Introduction.to.Algorithms

    4.4 The recursion-tree method for solving recurrences 88 4.5 The master method for solving recurrences 93 4.6 Proof of the master theorem 97 5 Probabilistic Analysis and Randomized Algorithms 114 5.1 ...

    微软内部资料-SQL性能优化5

    Each index row in node pages contains an index key (or set of keys for a composite index) and a pointer to a page at the next level for which the first key value is the same as the key value in the ...

    lrucacheleetcode-algorithm:记录学习算法的过程

    sorting link list list spanning tree tree graph stack hashing deliberate practicing 练习不足、缺陷之处 过程会不舒服 feeback 主动 github LeetCode Sulution Discuss 被动 code review 切题四件套 ...

    lrucacheleetcode-beihu-leetcode:力扣算法

    Sorting 排序算法 Graph 图 Hashing 哈希 Greedy 贪婪算法 Resursion/Backtrace 递归/回溯 Traversal 遍历 前中后序(In-Order/Pre-Order/Post-Order) Breadth-first/Depth-first search 广度优先、深度优先 Divide ...

    Sortable前端框架

    Sortable is a &lt;s&gt;minimalist&lt;/s&gt; JavaScript library for reorderable drag-and-drop lists. Demo: http://rubaxa.github.io/Sortable/ ## Features * Supports touch devices and [modern]...

    计算机编程英语单词,这里总结了大部分编程所需了解的英文单词,对与程序开发人员有很好的帮助,可以帮助他们更流畅的阅读外文资料文档。

    3. 图论(Graph Theory):涉及到连通分支(Connected Components)、拓扑排序(Topological Sorting)、最小生成树(Minimum Spanning Tree)、最短路径(Shortest Path)、传递闭包(Transitive Closure and ...

    VB编程资源大全(英文源码 其它)

    of a selected file.&lt;END&gt;&lt;br&gt;7 , logging.zip This is a bas that will log installation procedures so the file can be removed later.&lt;END&gt;&lt;br&gt;8 , savetree.zip This will save the info in a Tree View....

    编程词汇英汉对照.doc

    7. **图论**:连接组件(Connected Components)、拓扑排序(Topological Sorting)、最小生成树(Minimum Spanning Tree)、最短路径(Shortest Path)等,这些概念在网络分析和路由算法中十分关键。 8. **计算...

    最新Ehlib 5.2.84(含完整源代码,支持delphi XE)

    expapnding/collapsing state of new created elements of the grouping tree. GroupLevels: TGridDataGroupLevelsEh - Collection of group levels. Use this property to create template of the grouping. ...

Global site tag (gtag.js) - Google Analytics