Java Iterator toIterator(Collection col)

Here you can find the source of toIterator(Collection col)

Description

Get an iterator from a collection, returning null if collection is null

License

Open Source License

Parameter

Parameter Description
col The collection to be turned in to an iterator

Return

The resulting Iterator

Declaration

public static <E> Iterator<E> toIterator(Collection<E> col) 

Method Source Code

//package com.java2s;
/*/*from  ww w.ja  v  a2  s. c  om*/
 * MiscUtils.java
 *
 * Copyright (c) 1998 - 2006 BusinessTechnology, Ltd.
 * All rights reserved
 *
 * This program is the proprietary and confidential information
 * of BusinessTechnology, Ltd. and may be used and disclosed only
 * as authorized in a license agreement authorizing and
 * controlling such use and disclosure
 *
 * Millennium ERP system.
 *
 */

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**
     * Get an iterator from a collection, returning null if collection is null
     *
     * @param col The collection to be turned in to an iterator
     * @return The resulting Iterator
     */
    public static <E> Iterator<E> toIterator(Collection<E> col) {
        if (col == null)
            return null;
        else
            return col.iterator();
    }
}

Related

  1. size(Iterator iterator)
  2. splice(LinkedList list, Iterator iterator, LinkedList list2, V v)
  3. toArray(final Iterator iterator)
  4. toCollection(final Iterator iterator, final Collection c)
  5. toCommaSeparatedString(Iterator i)
  6. toIterator(final T[] data)
  7. toMap(final Iterator> iterator)
  8. toObjectIterator(Object[] objects)
  9. toSet(Iterator iteration)