parent, final Iterable Here you can find the source of subList(final Iterable parent, final Iterable
Parameter | Description |
---|---|
parent | a parameter |
child | a parameter |
Parameter | Description |
---|---|
IllegalArgumentException | if parent argument is bigger than child |
private static <P, C> List<C> subList(final Iterable<P> parent, final Iterable<C> child)
//package com.java2s; /*/*www . j av a 2s. c o m*/ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { /** * Create sublist view of child from element on [size-of-parent] position to * last element. * * @param parent * @param child * @return sublist view of child argument * @throws IllegalArgumentException * if parent argument is bigger than child */ private static <P, C> List<C> subList(final Iterable<P> parent, final Iterable<C> child) { Iterator<P> iParent = parent.iterator(); List<C> result = new ArrayList<>(); for (C arg : child) { if (iParent.hasNext()) { iParent.next(); } else { result.add(arg); } } if (iParent.hasNext()) { throw new IllegalArgumentException("Parent argument is bigger than child."); } return result; } }