Java Iterable containsSame(Iterable coll, Object obj)

Here you can find the source of containsSame(Iterable coll, Object obj)

Description

contains Same

License

Open Source License

Return

whether given coll contains given obj (obj must be the same as the one contained, not just equal).

Declaration

public static boolean containsSame(Iterable<?> coll, Object obj) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007 DSource.org 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
 *
 * Contributors://from w  w w.j a  v  a2 s.  co m
 *     Bruno Medeiros - initial implementation
 *******************************************************************************/

import java.util.Iterator;

public class Main {
    /** @return whether given coll contains given obj 
     * (obj must be the same as the one contained, not just equal). 
     */
    public static boolean containsSame(Iterable<?> coll, Object obj) {
        for (Iterator<?> iterator = coll.iterator(); iterator.hasNext();) {
            Object element = iterator.next();
            if (element == obj)
                return true;
        }
        return false;
    }
}

Related

  1. appendTo(StringBuilder appendable, Iterable parts, CharSequence separator)
  2. commafy(Iterable col, StringBuilder builder)
  3. convertIterable(final Iterable> iterables)
  4. createDelimitedString(Iterable iterable, String delimiter)
  5. createUpdateTemplate(String table, Iterable columns)
  6. equal(Iterable it1, Iterable it2)