Java List Contain contains(List list, List> listOfLists)

Here you can find the source of contains(List list, List> listOfLists)

Description

contains

License

Open Source License

Declaration

public static boolean contains(List<String> list, List<List<String>> listOfLists) 

Method Source Code

//package com.java2s;
/* /*from w w w.  j  a v  a 2  s .  co m*/
 * ScreenSlicer (TM) -- automatic, zero-config web scraping (TM)
 * Copyright (C) 2013-2015 Machine Publishers, LLC
 * ops@machinepublishers.com | screenslicer.com | machinepublishers.com
 * Cincinnati, Ohio, USA
 *
 * You can redistribute this program and/or modify it under the terms of the
 * GNU Affero General Public License version 3 as published by the Free
 * Software Foundation. Additional permissions or commercial licensing may be
 * available--see LICENSE file or contact Machine Publishers, LLC for details.
 * 
 * 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 General Public License version 3
 * for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * version 3 along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 * For general details about how to investigate and report license violations,
 * please see: https://www.gnu.org/licenses/gpl-violation.html
 * and email the author: ops@machinepublishers.com
 * Keep in mind that paying customers have more rights than the AGPL alone offers.
 */

import java.util.List;

public class Main {
    public static boolean contains(List<String> list, List<List<String>> listOfLists) {
        for (List<String> cur : listOfLists) {
            if (isSame(list, cur)) {
                return true;
            }
        }
        return false;
    }

    public static boolean isSame(List<String> lhs, List<String> rhs) {
        if (lhs == null && rhs == null) {
            return true;
        }
        if (lhs == null) {
            return false;
        }
        if (rhs == null) {
            return false;
        }
        if (lhs.size() != rhs.size()) {
            return false;
        }
        for (int i = 0; i < lhs.size(); i++) {
            if (!lhs.get(i).equals(rhs.get(i))) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. contains(List lsttor, Object val)
  2. contains(List list, Object element, int begin, int end)
  3. contains(List objects, Object object)
  4. contains(List listOfArrays, A[] array)
  5. contains(List list, int[] arr)
  6. contains(List list, String str, boolean bcaseSensitive)
  7. contains(List list, String string)
  8. contains(List list1, List list2)
  9. contains(List container, List list, Comparator comparator)