org.eclipse.jdt.internal.compiler.util.Sorting Maven / Gradle / Ivy
/**********************************************************************
* Copyright (c) 2008, 2014 Technical University Berlin, Germany and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* 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;
}
});
}
}