/*
* Copyright (c) 2005-2016 Vincent Vandenschrick. All rights reserved.
*
* This file is part of the Jspresso framework.
*
* Jspresso is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Jspresso 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Jspresso. If not, see <http://www.gnu.org/licenses/>.
*/
//package com.nowjava;
import java.util.ArrayList;// 来 自 n o w j a v a . c o m - 时 代 Java
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
public class Main {
public static void main(String[] argv) {
Collection smallCollection = java.util.Arrays.asList("asdf",
"nowjava.com");
Collection bigCollection = java.util.Arrays.asList("asdf",
"nowjava.com");
/*来自
时代Java - nowjava.com*/
System.out.println(java.util.Arrays
.toString(computeDifferenceIndices(smallCollection,
bigCollection)));
}
/**
* Computes the array of element indices which where added to a collection.
*
* @param smallCollection
* the original collection.
* @param bigCollection
* the collection with added elements.
* @return the the array of element indices which where added to the original
* collection
*/
public static int[] computeDifferenceIndices(
Collection<?> smallCollection, Collection<?> bigCollection) {
List<Integer> addedIndices = new ArrayList<>();
int index = 0;
for (Iterator<?> ite = bigCollection.iterator(); ite.hasNext(); index++) {
if (smallCollection == null
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。