Here you can find the source of contains(int[] match, List
Parameter | Description |
---|---|
match | the array to match |
container | the list of arrays to test |
public static boolean contains(int[] match, List<int[]> container)
//package com.java2s; /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) * Copyright (C) 2014, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Affero Public License for more details. * * You should have received a copy of the GNU Affero Public License * along with this program. If not, see http://www.gnu.org/licenses. * * http://numenta.org/licenses/// w w w . j a va 2 s . c o m * --------------------------------------------------------------------- */ import java.util.Arrays; import java.util.List; public class Main { /** * Returns a flag indicating whether the container list contains an * array which matches the specified match array. * * @param match the array to match * @param container the list of arrays to test * @return true if so, false if not */ public static boolean contains(int[] match, List<int[]> container) { int len = container.size(); for (int i = 0; i < len; i++) { if (Arrays.equals(match, container.get(i))) { return true; } } return false; } }