org.rutil.collection
Class CollectionsHelper

java.lang.Object
  extended by org.rutil.collection.CollectionsHelper

public final class CollectionsHelper
extends java.lang.Object

A helper class with utility methods to deal with some common collection operations.

Author:
mohan

Field Summary
static java.util.Iterator EMPTY_ITERATOR
           
static SingleLinkedList EMPTY_LIST
           
 
Constructor Summary
CollectionsHelper()
           
 
Method Summary
static
<T> SingleLinkedList<T>
addAll(java.util.Iterator<T> srcList, SingleLinkedList<T> dstList)
           
static
<T> SingleLinkedList<T>
addAll(SingleLinkedList<T> srcList, SingleLinkedList<T> dstList)
           
static
<E> java.util.Iterator<E>
emptyIterator()
          An iterator with "hasNext" always returning false, next and remove throwing an exception
static
<E> SingleLinkedList<E>
emptyList()
           
static
<E> java.util.Iterator<E>
unmodifiableIterator(java.util.Iterator<E> iterator)
          A new iterator with wraps the iterator parameter but disallows remove operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ITERATOR

public static final java.util.Iterator EMPTY_ITERATOR

EMPTY_LIST

public static final SingleLinkedList EMPTY_LIST
Constructor Detail

CollectionsHelper

public CollectionsHelper()
Method Detail

emptyIterator

public static <E> java.util.Iterator<E> emptyIterator()
An iterator with "hasNext" always returning false, next and remove throwing an exception

Returns:
returns an empty iterator .

unmodifiableIterator

public static <E> java.util.Iterator<E> unmodifiableIterator(java.util.Iterator<E> iterator)
A new iterator with wraps the iterator parameter but disallows remove operation.

Parameters:
iterator -
Returns:
new read-only iterator

emptyList

public static <E> SingleLinkedList<E> emptyList()
Returns:
empty, unmodifiable single linked list

addAll

public static <T> SingleLinkedList<T> addAll(SingleLinkedList<T> srcList,
                                             SingleLinkedList<T> dstList)
Parameters:
srcList - source list
dstList - destination list or null
Returns:
a list that contains all the elements from dstList and srcList.

addAll

public static <T> SingleLinkedList<T> addAll(java.util.Iterator<T> srcList,
                                             SingleLinkedList<T> dstList)
Parameters:
srcList - source list
dstList - destination list or null
Returns:
a list that contains all the elements from dstList and srcList.