org.eclipse.jdt.internal.compiler.util.Sorting Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecj Show documentation
Show all versions of ecj Show documentation
Eclipse Compiler for Java(TM)
/**********************************************************************
* Copyright (c) 2008, 2014 Technical University Berlin, Germany and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Stephan Herrmann - Initial API and implementation
**********************************************************************/
package org.eclipse.jdt.internal.compiler.util;
import java.util.Arrays;
import java.util.Comparator;
import org.eclipse.jdt.internal.compiler.lookup.InferenceVariable;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
/**
* Sorting utilities.
* Originally developed for the Object Teams project.
*/
public class Sorting {
/**
* Topological sort for types
* Guarantee: supertypes come before subtypes.
*/
public static ReferenceBinding[] sortTypes(ReferenceBinding[] types) {
int len = types.length;
ReferenceBinding[] unsorted = new ReferenceBinding[len];
ReferenceBinding[] sorted = new ReferenceBinding[len];
System.arraycopy(types, 0, unsorted, 0, len);
int o = 0;
for(int i=0; i 0 && !methods[0].isAbstract()))
return methods;
MethodBinding[] copy = new MethodBinding[length];
int idx = 0;
for (int i=0; i 0 && methods[0].isAbstract()))
return methods;
MethodBinding[] copy = new MethodBinding[length];
int idx = 0;
for (int i=0; i() {
@Override
public int compare(InferenceVariable iv1, InferenceVariable iv2) {
return iv1.rank - iv2.rank;
}
});
}
}