cern.colt.Swapper Java Examples

The following examples show how to use cern.colt.Swapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataRegistry.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Implementation of {@link DataHandle#sort(Swapper, int, int, boolean, int...)}
 * @param handle
 * @param swapper
 * @param from
 * @param to
 * @param ascending
 * @param columns
 */
protected void sort(final DataHandle handle,
                    final Swapper swapper,
                    final int from,
                    final int to,
                    final boolean ascending,
                    final int... columns) {
    handle.checkColumns(columns);
    handle.checkRow(from, handle.getNumRows());
    handle.checkRow(to, handle.getNumRows());
    
    if (handle instanceof DataHandleSubset){
        sortSubset((DataHandleSubset)handle, swapper, from, to, ascending, columns);
    } else {
        sortAll(handle, swapper, from, to, ascending, columns);
    }
}
 
Example #2
Source File: RankArray.java    From systemsgenetics with GNU General Public License v3.0 4 votes vote down vote up
public RankArray() {
    swapperdouble = new cern.colt.Swapper() {
        @Override
        public void swap(int a, int b) {
            double t1;
            int t2;
            t1 = xdouble[a];
            xdouble[a] = xdouble[b];
            xdouble[b] = t1;
            t2 = ydouble[a];
            ydouble[a] = ydouble[b];
            ydouble[b] = t2;
        }
    };

    compdouble = new IntComparator() {
        @Override
        public int compare(int a, int b) {
            return xdouble[a] == xdouble[b] ? 0 : (xdouble[a] < xdouble[b] ? -1 : 1);
        }
    };

    swapper = new cern.colt.Swapper() {
        @Override
        public void swap(int a, int b) {
            float t1;
            int t2;
            t1 = x[a];
            x[a] = x[b];
            x[b] = t1;
            t2 = y[a];
            y[a] = y[b];
            y[b] = t2;
        }
    };

    comp = new IntComparator() {
        @Override
        public int compare(int a, int b) {
            return x[a] == x[b] ? 0 : (x[a] < x[b] ? -1 : 1);
        }
    };
}
 
Example #3
Source File: DataHandle.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * Sorts the dataset according to the given columns. Will sort input and
 * output analogously.
 *
 * @param swapper A swapper
 * @param ascending Sort ascending or descending
 * @param columns An integer array containing column indicides
 */
public void sort(Swapper swapper, boolean ascending, int... columns) {
    checkReleased();
    registry.sort(this, swapper, ascending, columns);
}
 
Example #4
Source File: DataHandle.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * Sorts the dataset according to the given columns and the given range.
 * Will sort input and output analogously.
 *
 * @param swapper A swapper
 * @param from The lower bound
 * @param to The upper bound
 * @param ascending Sort ascending or descending
 * @param columns An integer array containing column indicides
 */
public void sort(Swapper swapper, int from, int to, boolean ascending, int... columns) {
    checkReleased();
    registry.sort(this, swapper, from, to, ascending, columns);
}
 
Example #5
Source File: DataRegistry.java    From arx with Apache License 2.0 2 votes vote down vote up
/**
 * Implementation of {@link DataHandle#sort(Swapper, boolean, int...)}
 * @param handle
 * @param swapper
 * @param ascending
 * @param columns
 */
protected void sort(final DataHandle handle, final Swapper swapper, final boolean ascending, final int... columns) {
    sort(handle, swapper, 0, handle.getNumRows(), ascending, columns);
}