當前位置: 首頁>>代碼示例>>Java>>正文


Java Collections.sort方法代碼示例

本文整理匯總了Java中java.util.Collections.sort方法的典型用法代碼示例。如果您正苦於以下問題:Java Collections.sort方法的具體用法?Java Collections.sort怎麽用?Java Collections.sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.sort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: WeekLessonDiaLogItemAdapter

import java.util.Collections; //導入方法依賴的package包/類
public WeekLessonDiaLogItemAdapter(@Nonnull Context context, @Nonnull List<WeekLessonDialogItem> list, int text_color, int bg_color) {
    super(context, null);
    mIsExpandPosList = new ArrayList<>();
    Collections.sort(list, weekLessonDialogItemComparator);
    mListData.addAll(list);

    for (int i = 0; i < mListData.size(); i++) {
        mIsExpandPosList.add(false);
    }

    try {
        mRepeatList = mDbHelper.getRepeatList();
    } catch (NullObjectException e) {
        Log.d(TAG, e.toString());
    }

    mTextColor = text_color;
    mBgColor = bg_color;

    Resources resources = mContext.getResources();
    mStatus_New = resources.getString(R.string.status_new);
    mStatus_Unsaved = resources.getString(R.string.status_change);
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:24,代碼來源:WeekLessonDiaLogItemAdapter.java

示例2: toggleFileTree

import java.util.Collections; //導入方法依賴的package包/類
private void toggleFileTree(File file){
    //路徑名
    mTvPath.setText(getString(R.string.nb_file_path,file.getPath()));
    //獲取數據
    File[] files = file.listFiles(new SimpleFileFilter());
    //轉換成List
    List<File> rootFiles = Arrays.asList(files);
    //排序
    Collections.sort(rootFiles,new FileComparator());
    //加入
    mAdapter.refreshItems(rootFiles);
    //反饋
    if (mListener != null){
        mListener.onCategoryChanged();
    }
}
 
開發者ID:newbiechen1024,項目名稱:NovelReader,代碼行數:17,代碼來源:FileCategoryFragment.java

示例3: onActualMessagePeerMessageReceived

import java.util.Collections; //導入方法依賴的package包/類
private void onActualMessagePeerMessageReceived(int accountId, int peerId, int unreadCount, Message message) {
    if (accountId != this.dialogsOwnerId) {
        return;
    }

    int index = indexOf(this.dialogs, peerId);

    if (index != -1) {
        Dialog dialog = this.dialogs.get(index);

        dialog.setMessage(message)
                .setUnreadCount(unreadCount)
                .setLastMessageId(message.getId());

        if (dialog.isChat()) {
            dialog.setInterlocutor(message.getSender());
        }

        Collections.sort(this.dialogs, COMPARATOR);
    }

    safeNotifyDataSetChanged();
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:24,代碼來源:DialogsPresenter.java

示例4: getCountries

import java.util.Collections; //導入方法依賴的package包/類
public static List<LocationDto> getCountries(LocationDto area) throws ExternalServiceException {
    try {
        List<LocationDto> countries = new ArrayList<LocationDto>();
        if (area == null) {
            return Collections.emptyList();
        }
        for (LocationDto loc : area.getChildren()) {
            if (!isAlive(loc)) {
                continue;
            }
            LocationType type = getLocationType(loc);
            if (type != null && type == LocationType.COUNTRY) {
                countries.add(loc);
            }
        }
        Collections.sort(countries, new LocationComparator());
        return countries;
    } catch (Exception e) {
        throw ExceptionUtils.getExternalServiceException(e);
    }
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:22,代碼來源:LocationUtil.java

示例5: toSort

import java.util.Collections; //導入方法依賴的package包/類
/**
 * 簡單的單維比較排序(正序)
 * 
 * @author      ZhengWei(HY)
 * @createDate  2015-12-10
 * @version     v1.0
 *
 * @param i_Values
 * @return
 */
@SafeVarargs
public final static <T extends Comparable<? super T>> List<T> toSort(T ... i_Values)
{
    if ( Help.isNull(i_Values) )
    {
        return new ArrayList<T>(0);
    }
    
    List<T> v_Values = new ArrayList<T>(i_Values.length);
    
    for (T v_Item : i_Values)
    {
        v_Values.add(v_Item);
    }
    
    Collections.sort(v_Values);
    
    return v_Values;
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.base,代碼行數:30,代碼來源:Help.java

示例6: orderCollection

import java.util.Collections; //導入方法依賴的package包/類
/**
 * Ordernar uma lista
 * @param collecao 
 * @param orderMode 
 */
public static void orderCollection (List collecao, OrederBy orderMode)
{
    Float f;
    Integer i;
    if (orderMode == OrederBy.ASC)
        Collections.sort(collecao);
    else
    {
        Comparator c = (Comparator) (Object o1, Object o2) -> 
        {
            try
            {
                Comparable co1 = (Comparable) o1;
                if (o1.getClass().equals(o2.getClass()))
                {
                    return  co1.compareTo(o2) * -1;
                }
            }catch(Exception ex) {}
            return 0;
        };
        Collections.sort(collecao, c); 
    }
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:29,代碼來源:OperacaoString.java

示例7: sortCraftManager

import java.util.Collections; //導入方法依賴的package包/類
public static void sortCraftManager()
{
    bake();
    FMLLog.fine("Sorting recipes");
    warned.clear();
    Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:RecipeSorter.java

示例8: dumpRandomSentences

import java.util.Collections; //導入方法依賴的package包/類
/**
 * Dump a set of random sentences that fit this grammar
 * 
 * @param count
 *            dumps no more than this. May dump less than this depending
 *            upon the number of uniqe sentences in the grammar.
 */
public void dumpRandomSentences(int count) {
	Set<String> set = new HashSet<String>();
	for (int i = 0; i < count; i++) {
		String s = getRandomSentence();
		if (!set.contains(s)) {
			set.add(s);
		}
	}
	List<String> sampleList = new ArrayList<String>(set);
	Collections.sort(sampleList);

	for (String sentence : sampleList) {
		System.out.println(sentence);
	}
}
 
開發者ID:CognitiveModeling,項目名稱:BrainControl,代碼行數:23,代碼來源:GrammarDump.java

示例9: setWidgets

import java.util.Collections; //導入方法依賴的package包/類
public void setWidgets(MultiHashMap<PackageItemInfo, WidgetItem> widgets) {
    mEntries.clear();
    WidgetItemComparator widgetComparator = new WidgetItemComparator();

    for (Map.Entry<PackageItemInfo, ArrayList<WidgetItem>> entry : widgets.entrySet()) {
        WidgetListRowEntry row = new WidgetListRowEntry(entry.getKey(), entry.getValue());
        row.titleSectionName = mIndexer.computeSectionName(row.pkgItem.title);
        Collections.sort(row.widgets, widgetComparator);
        mEntries.add(row);
    }

    Collections.sort(mEntries, new WidgetListRowEntryComparator());
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:WidgetsListAdapter.java

示例10: toSetOf

import java.util.Collections; //導入方法依賴的package包/類
private static byte[] toSetOf(Collection<?> values, Asn1Type elementType)
        throws Asn1EncodingException {
    List<byte[]> serializedValues = new ArrayList<>(values.size());
    for (Object value : values) {
        serializedValues.add(JavaToDerConverter.toDer(value, elementType, null));
    }
    if (serializedValues.size() > 1) {
        Collections.sort(serializedValues, ByteArrayLexicographicComparator.INSTANCE);
    }
    return createTag(
            BerEncoding.TAG_CLASS_UNIVERSAL, true, BerEncoding.TAG_NUMBER_SET,
            serializedValues.toArray(new byte[0][]));
}
 
開發者ID:F8LEFT,項目名稱:FApkSigner,代碼行數:14,代碼來源:Asn1DerEncoder.java

示例11: updateOrder

import java.util.Collections; //導入方法依賴的package包/類
public void updateOrder() {
    synchronized (mAddedAppItems) {
        Collections.sort(mAddedAppItems, new AppItem.IndexComparator());
    }
    notifyListener();
    mHandler.obtainMessage(MSG_SAVE_ORDER).sendToTarget();
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:8,代碼來源:AppManager.java

示例12: processResult

import java.util.Collections; //導入方法依賴的package包/類
public void processResult(int rc, String path, Object ctx,
        List<String> children, Stat stat)
{
    this.children =
        (children == null ? new ArrayList<String>() : children);
    Collections.sort(this.children);
    super.processResult(Code.get(rc), path, ctx);
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:9,代碼來源:AsyncOps.java

示例13: getHardwareProperties

import java.util.Collections; //導入方法依賴的package包/類
/**
 * Returns the hardware properties defined in
 * {@link AvdManager#HARDWARE_INI} as a {@link Map}.
 *
 * This is intended to be dumped in the config.ini and already contains
 * the device name, manufacturer and device hash.
 *
 * @param d The {@link Device} from which to derive the hardware properties.
 * @return A {@link Map} of hardware properties.
 */
@NonNull
public static Map<String, String> getHardwareProperties(@NonNull Device d) {
    Map<String, String> props = getHardwareProperties(d.getDefaultState());
    for (State s : d.getAllStates()) {
        if (s.getKeyState().equals(KeyboardState.HIDDEN)) {
            props.put("hw.keyboard.lid", getBooleanVal(true));
        }
    }

    HashFunction md5 = Hashing.md5();
    Hasher hasher = md5.newHasher();

    ArrayList<String> keys = new ArrayList<String>(props.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        if (key != null) {
            hasher.putString(key, Charsets.UTF_8);
            String value = props.get(key);
            hasher.putString(value == null ? "null" : value, Charsets.UTF_8);
        }
    }
    // store the hash method for potential future compatibility
    String hash = "MD5:" + hasher.hash().toString();
    props.put(AvdManager.AVD_INI_DEVICE_HASH_V2, hash);
    props.remove(AvdManager.AVD_INI_DEVICE_HASH_V1);

    props.put(AvdManager.AVD_INI_DEVICE_NAME, d.getId());
    props.put(AvdManager.AVD_INI_DEVICE_MANUFACTURER, d.getManufacturer());
    return props;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:41,代碼來源:DeviceManager.java

示例14: testInnerClassSort

import java.util.Collections; //導入方法依賴的package包/類
public void testInnerClassSort()
{
  Comparator<? super Coordinate> coordSorter = new Comp();
  List<? extends Coordinate>  points = (List)makeSampleList();
  Collections.sort( points, coordSorter );
  assertEquals( makeSampleList_Sorted(), points );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:8,代碼來源:StructuralTypeTest.java

示例15: calculateMin

import java.util.Collections; //導入方法依賴的package包/類
private int calculateMin(List<Integer> items) {
    Collections.sort(items);
    return (items.size() > 0) ? items.get(0) : 0;
}
 
開發者ID:adr,項目名稱:eadlsync,代碼行數:5,代碼來源:Statistic.java


注:本文中的java.util.Collections.sort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。