Esempio n. 1
0
 public static void main(String[] args) {
   init();
   // print(arrays);
   ISort sort = SortFactory.createSort(SortType.QUICK);
   long start = System.currentTimeMillis();
   sort.sort(arrays);
   long end = System.currentTimeMillis();
   System.out.println("waste time: " + (end - start) + "ms");
   // print(arrays);
   validate(arrays);
 }
 /**
  * Selects the specified search category. If the selected category is changed, this method updates
  * the sorted list.
  */
 @Override
 public void setSelectedCategory(SearchCategory selectedCategory) {
   if (this.selectedCategory != selectedCategory) {
     this.selectedCategory = selectedCategory;
     // Dispose of existing visible and sorted lists.
     if (visibleResultList != null) {
       visibleResultList.dispose();
       sortedResultList.dispose();
     }
     // Update visible and sorted lists.
     EventList<VisualSearchResult> filteredList = getCategorySearchResults(selectedCategory);
     sortedResultList = GlazedListsFactory.sortedList(filteredList, null);
     visibleResultList = GlazedListsFactory.filterList(sortedResultList, new VisibleMatcher());
     sortedResultList.setComparator(
         (sortOption != null) ? SortFactory.getSortComparator(sortOption) : null);
   }
 }
 /** Sets the sort option. This method updates the sorted list by changing the sort comparator. */
 @Override
 public void setSortOption(SortOption sortOption) {
   this.sortOption = sortOption;
   sortedResultList.setComparator(
       (sortOption != null) ? SortFactory.getSortComparator(sortOption) : null);
 }