Java List Contain containsInOrder(List a, List b)

Here you can find the source of containsInOrder(List a, List b)

Description

contains In Order

License

Open Source License

Declaration

public static <T> boolean containsInOrder(List<T> a, List<T> b) 

Method Source Code

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

import java.util.List;

public class Main {
    public static <T> boolean containsInOrder(List<T> a, List<T> b) {
        int lastMatch = -1;

        for (int i = 0; i < b.size(); i++) {
            T find = b.get(i);/* ww  w .  j a v  a2  s.co  m*/
            boolean found = false;

            for (int k = lastMatch + 1; k < a.size(); k++) {
                if (a.get(k).equals(find)) {
                    lastMatch = k;
                    found = true;
                    break;
                }
            }

            if (!found) {
                return false;
            }
        }

        return true;
    }
}

Related

  1. containsIgnoreCase(String str, String... list)
  2. containsInAnyOrder(final List test, final List control)
  3. containsIndex(int index, List objects)
  4. containsInEach(List first, List second)
  5. ContainsInList(String list, String value)
  6. containsInstance(final List list, final Class clazz)
  7. containsInstance(List list, Object object)
  8. containsItems(List smallerList, List largerList)
  9. containsNonPositives(List vals)