Here you can find the source of intersect(boolean[] mask, int[] examples, boolean[] intersection)
Parameter | Description |
---|---|
mask | An examples mask |
examples | The list of examples to intersect with |
intersection | The examples mask with the intersection of the first 2 arguments, must be the same size as mask. |
public static int intersect(boolean[] mask, int[] examples, boolean[] intersection)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { /**/*w w w.ja v a 2 s .c o m*/ * A generic intersect function that * * @param mask * An examples mask * @param examples * The list of examples to intersect with * @param intersection * The examples mask with the intersection of the first 2 * arguments, must be the same size as mask. * @return The number of true elements in the intersection mask. */ public static int intersect(boolean[] mask, int[] examples, boolean[] intersection) { if (intersection.length != mask.length) throw new RuntimeException("Argument and return value have different length."); Arrays.fill(intersection, false); int count = 0; for (int i = 0; i < examples.length; i++) if (mask[examples[i]]) { intersection[examples[i]] = true; count++; } return (count); } }