@@ -0,0 +1,1704 @@
+/*%0A * LensKit, an open source recommender systems toolkit.%0A * Copyright 2010-2013 Regents of the University of Minnesota and contributors%0A * Work on LensKit has been funded by the National Science Foundation under%0A * grants IIS 05-34939, 08-08692, 08-12148, and 10-17697.%0A *%0A * This program is free software; you can redistribute it and/or modify%0A * it under the terms of the GNU Lesser General Public License as%0A * published by the Free Software Foundation; either version 2.1 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS%0A * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more%0A * details.%0A *%0A * You should have received a copy of the GNU General Public License along with%0A * this program; if not, write to the Free Software Foundation, Inc., 51%0A * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.%0A */%0Apackage org.grouplens.lenskit.eval.data.crossfold;%0A%0Aimport static java.lang.Math.min;%0A%0Aimport java.util.List;%0A%0A/**%0A * Partition the last part of list by holding out a fixed number of elements.%0A * Using the number of retain part of items to hold out.%0A *%0A * @param %3CE%3E%0A * @author Lingfei He %3CLingfei@cs.umn.edu%3E%0A */%0Apublic class RetainNPartition%3CE%3E implements PartitionAlgorithm%3CE%3E %7B%0A%0A    private int count;%0A%0A    /**%0A     * Create a count partitioner.%0A     *%0A     * @param n The number of items to put in the train partition.%0A     */%0A    public RetainNPartition(int n) %7B%0A        count = n;%0A    %7D%0A%0A    @Override%0A    public int partition(List%3CE%3E data) %7B%0A        return min(count, data.size());%0A    %7D%0A%0A%7D%0A

Add RetainNPartition class to support the retain-N protocol