1
/*******************************************************************************
2
* Copyright (c) 2000, 2008 QNX Software Systems and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - Initial API and implementation
10
* Anton Leherbauer (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.ui.text.contentassist;
15
import java.util.Comparator;
17
import org.eclipse.cdt.ui.text.ICCompletionProposal;
19
public class CCompletionProposalComparator implements Comparator<ICCompletionProposal> {
21
private boolean fOrderAlphabetically;
24
* Constructor for CompletionProposalComparator.
26
public CCompletionProposalComparator() {
27
fOrderAlphabetically= false;
30
public void setOrderAlphabetically(boolean orderAlphabetically) {
31
fOrderAlphabetically= orderAlphabetically;
35
* @see Comparator#compare(Object, Object)
37
public int compare(ICCompletionProposal c1, ICCompletionProposal c2) {
38
if (!fOrderAlphabetically) {
39
int relevanceDif= c2.getRelevance() - c1.getRelevance();
40
if (relevanceDif != 0) {
45
String id1 = c1.getIdString();
46
String id2 = c2.getIdString();
48
return id1.compareTo(id2);