it.unimi.dsi.fastutil.ints.IntSortedSet Java Examples

The following examples show how to use it.unimi.dsi.fastutil.ints.IntSortedSet. 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: GreedyReranker.java    From RankSys with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Selects the next element of the permutation that maximizes the 
 * objective function.
 *
 * @param remainingI positions of the original recommendation that have
 * not been selected yet.
 * @param list the list of item-score pairs of the input recommendation
 * @return the next element of the permutation that maximizes the 
 * objective function.
 */
protected int selectItem(IntSortedSet remainingI, List<Tuple2od<I>> list) {
    double[] max = new double[]{Double.NEGATIVE_INFINITY};
    int[] bestI = new int[]{remainingI.firstInt()};
    remainingI.forEach(i -> {
        double value = value(list.get(i));
        if (isNaN(value)) {
            return;
        }
        if (value > max[0] || (value == max[0] && i < bestI[0])) {
            max[0] = value;
            bestI[0] = i;
        }
    });

    return bestI[0];
}
 
Example #2
Source File: IntervalTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
public void testSubsets() {
	for( int i = 0; i < 10; i++ )
		for( int j = i - 1; j < 10; j++ ) {
			Interval interval = j < i ? EMPTY_INTERVAL : Interval.valueOf( i, j );
			IntSortedSet set = toSortedSet( interval );
			assertEquals( set, interval );
			assertTrue( Arrays.equals( IntIterators.unwrap( set.iterator() ), IntIterators.unwrap( set.iterator() ) ) );
			assertEquals( new IntOpenHashSet( set ), interval );
			for( int k = j - 1; k <= i + 1; k++ ) {
				assertTrue( Arrays.equals( IntIterators.unwrap( set.iterator( k ) ), IntIterators.unwrap( set.iterator( k ) ) ) );
				assertEquals( set.headSet( k ), interval.headSet( k ) );
				assertEquals( set.tailSet( k ), interval.tailSet( k ) );
				for( int l = k; l <= i + 1; l++ )
					assertEquals( set.subSet( k, l ), interval.subSet( k, l ) );
			}
		}
}
 
Example #3
Source File: LambdaReranker.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected int selectItem(IntSortedSet remainingI, List<Tuple2od<I>> list) {
    novMap = new Object2DoubleOpenHashMap<>();
    relStats = new Stats();
    novStats = new Stats();
    remainingI.forEach(i -> {
        Tuple2od<I> itemValue = list.get(i);
        double nov = nov(itemValue);
        novMap.put(itemValue.v1, nov);
        relStats.accept(itemValue.v2);
        novStats.accept(nov);
    });
    return super.selectItem(remainingI, list);
}
 
Example #4
Source File: Interval.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public IntSortedSet subSet( final int from, final int to ) {
	if ( this == EMPTY_INTERVAL ) return this;
	if ( from > to ) throw new IllegalArgumentException( "Start element (" + from  + ") is larger than end element (" + to + ")" );
	if ( to <= left || from > right || from == to ) return EMPTY_INTERVAL;
	if ( from <= left && to > right ) return this;
	return valueOf( Math.max( left, from ), Math.min( right, to - 1 ) );
}
 
Example #5
Source File: DataFixerUpper.java    From DataFixerUpper with MIT License 4 votes vote down vote up
protected DataFixerUpper(final Int2ObjectSortedMap<Schema> schemas, final List<DataFix> globalList, final IntSortedSet fixerVersions) {
    this.schemas = schemas;
    this.globalList = globalList;
    this.fixerVersions = fixerVersions;
}
 
Example #6
Source File: DataFixerUpper.java    From DataFixerUpper with MIT License 4 votes vote down vote up
protected IntSortedSet fixerVersions() {
    return fixerVersions;
}
 
Example #7
Source File: Interval.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public IntSortedSet headSet( final int to ) {
	if ( this == EMPTY_INTERVAL ) return this;
	if ( to > left ) return to > right ? this : valueOf( left, to - 1 );
	else return EMPTY_INTERVAL;
}
 
Example #8
Source File: Interval.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public IntSortedSet tailSet( final int from ) {
	if ( this == EMPTY_INTERVAL ) return this;
	if ( from <= right ) return from <= left ? this : valueOf( from, right );
	else return EMPTY_INTERVAL;
}
 
Example #9
Source File: IntervalTest.java    From database with GNU General Public License v2.0 4 votes vote down vote up
private IntSortedSet toSortedSet( Interval interval ) {
	if ( interval == EMPTY_INTERVAL ) return IntSortedSets.EMPTY_SET;
	IntSortedSet set = new IntRBTreeSet();
	for( int i = interval.left; i <= interval.right; i++ ) set.add( i );
	return set;
}