class TreeDataIndex {

    public TreeDataIndex filter(TreeFilter filter) {
        int projSize = 0;
        for (int i = 0; i < rowsCount(); i++) {
            if (filter.test(featuresInSortedOrder(i, 0)))
                projSize++;
        }

        int[][] prj = new int[projSize][columnsCount()];
        for (int feature = 0; feature < columnsCount(); feature++) {
            int ptr = 0;
            for (int row = 0; row < rowsCount(); row++) {
                if (filter.test(featuresInSortedOrder(row, feature)))
                    prj[ptr++][feature] = idx[row][feature];
            }
        }

        return new TreeDataIndex(prj, features, labels);
    }

    public  TreeDataIndex(double[][] features, double[] labels);
    private  TreeDataIndex(int[][] idxProj, double[][] features, double[] labels);

}