Java List Contain contains(List list, Object element, int begin, int end)

Here you can find the source of contains(List list, Object element, int begin, int end)

Description

contains

License

Open Source License

Declaration

public static boolean contains(List<?> list, Object element, int begin, int end) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static boolean contains(List<?> list, Object element, int begin, int end) {
        return indexOf(list, element, begin, end) != -1;
    }// w  w  w  .  ja va  2 s. com

    public static boolean contains(List<?> list, Object element, int begin) {
        return contains(list, element, begin, list.size());
    }

    public static int indexOf(List<?> list, Object element, int begin, int end) {
        begin = Math.min(begin, list.size());
        end = Math.min(end, list.size());

        if (begin == 0 && end == list.size())
            return list.indexOf(element);

        for (int i = begin; i < end; i++) {
            if (Objects.equals(element, list.get(i)))
                return i;
        }

        return -1;
    }

    public static int indexOf(List<?> list, Object element, int begin) {
        return indexOf(list, element, begin, list.size());
    }
}

Related

  1. contains(int[] match, List container)
  2. contains(int[] subject, int[][] list)
  3. contains(List aList, Object anObj)
  4. contains(List list, Object obj)
  5. contains(List lsttor, Object val)
  6. contains(List objects, Object object)
  7. contains(List listOfArrays, A[] array)
  8. contains(List list, int[] arr)
  9. contains(List list, List> listOfLists)