com.aliasi.util
Class Collections

java.lang.Object
  extended by com.aliasi.util.Collections

Deprecated. Use methods as indicated on a per-method basis.

@Deprecated
public class Collections
extends Object

Static utility methods for processing collections.

Since:
LingPipe1.0
Version:
3.9.1
Author:
Bob Carpenter

Method Summary
static
<E> void
addAll(Collection<? super E> c, E[] xs)
          Deprecated. Use java.util.Collections.addAll(Collection,Object[]) instead.
static
<E> int
compare(E e1, E e2, Comparator<? super E> comparator)
          Deprecated. Implement directly using the comparator or objects.
static void elementsToStringBuilder(StringBuilder sb, Collection<?> c)
          Deprecated. Use sb.append(c.toString()) instead.
static
<E> E
getFirst(List<? extends E> l)
          Deprecated. Use l.get(0) instead.
static
<E> E
getFirst(Set<? extends E> s)
          Deprecated. Use set.iterator().next() instead.
static boolean intersects(Set<?> set1, Set<?> set2)
          Deprecated. Use !java.util.Collections.disjoint(set1,set2).
static boolean isSingleton(Collection<?> c)
          Deprecated. Use c.size() == 1 instead.
static String listToString(List<?> ls)
          Deprecated. Use List.toString() instead.
static void listToStringBuilder(StringBuilder sb, List<?> ls)
          Deprecated. Use sb.append(ls.toString()).
static String setToString(Set<?> s)
          Deprecated. Use Set.toString() instead.
static void setToStringBuilder(StringBuilder sb, Set<?> c)
          Deprecated. Use sb.append(c.toString()) instead.
static int[] toIntArray(Collection<? extends Number> cs)
          Deprecated. Implement directly using Number.intValue().
static String[] toStringArray(Collection<?> c)
          Deprecated. Use Collection.toArray(Object[]) instead.
static void toStringArray(Collection<?> c, String[] members)
          Deprecated. Use Collection.toArray(Object[]) instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isSingleton

@Deprecated
public static boolean isSingleton(Collection<?> c)
Deprecated. Use c.size() == 1 instead.

Returns true if the specified collection contains exactly one member.

Parameters:
c - Collection to test.
Returns:
true if the specified collection contains exactly one member.

getFirst

@Deprecated
public static <E> E getFirst(List<? extends E> l)
Deprecated. Use l.get(0) instead.

Returns the first member of the specified list.

Type Parameters:
E - type of objects in the list
Parameters:
l - List whose first member is returned.
Returns:
First member of the specified list.
Throws:
IndexOutOfBoundsException - If the list is empty.

getFirst

@Deprecated
public static <E> E getFirst(Set<? extends E> s)
Deprecated. Use set.iterator().next() instead.

Returns the first member of the specified set.

Type Parameters:
E - type of objects in the list
Parameters:
s - Set whose first member is returned.
Returns:
First member of the specified set.
Throws:
NoSuchElementException - If the set is empty.

intersects

@Deprecated
public static boolean intersects(Set<?> set1,
                                            Set<?> set2)
Deprecated. Use !java.util.Collections.disjoint(set1,set2).

Returns true if the specified sets have at least one element in common.

Parameters:
set1 - First set.
set2 - Second set.
Returns:
true if the specified sets have at least one element in common.

addAll

@Deprecated
public static <E> void addAll(Collection<? super E> c,
                                         E[] xs)
Deprecated. Use java.util.Collections.addAll(Collection,Object[]) instead.

Adds the elements from the specified array to the specified collection.

Type Parameters:
E - type of objects in the collection
Parameters:
c - Collection to which objects are added.
xs - Objects to add to the collection.

toStringArray

@Deprecated
public static String[] toStringArray(Collection<?> c)
Deprecated. Use Collection.toArray(Object[]) instead.

Returns the elements in the specified collection as an array after converting each to a string. The strings in the array will be ordered as by the collection's iterator.

Parameters:
c - Collection to convert to an array.
Returns:
Elements of specified collection as an array of strings.

toStringArray

@Deprecated
public static void toStringArray(Collection<?> c,
                                            String[] members)
Deprecated. Use Collection.toArray(Object[]) instead.

Writes the elements in the specified collection into the specified array as strings, beginning with the first position of the array. The elements in the array will be ordered as by the collection's iterator. The array may be longer than the collection, in which case nothing is done to the remaining members of the array.

Parameters:
c - Collection to convert to an array.
members - String rray to write collection into.
Throws:
IndexOutOfBoundsException - If the size of the collection is greater than the length of the array.

toIntArray

@Deprecated
public static int[] toIntArray(Collection<? extends Number> cs)
Deprecated. Implement directly using Number.intValue().

Returns an array of int consisting of the elements of the specified collection converted to int.

Parameters:
cs - Collection of integers to convert to ints.
Returns:
Array of ints derived from collection of integers.

setToString

@Deprecated
public static String setToString(Set<?> s)
Deprecated. Use Set.toString() instead.

Returns a string-based representation of the specified set.

Parameters:
s - Set to convert to string.
Returns:
String-based representation of the specified set.

listToString

@Deprecated
public static String listToString(List<?> ls)
Deprecated. Use List.toString() instead.

Returns a string-based representation of the specified list.

Parameters:
ls - List to convert to string.
Returns:
String-based representation of the specified list.

listToStringBuilder

@Deprecated
public static void listToStringBuilder(StringBuilder sb,
                                                  List<?> ls)
Deprecated. Use sb.append(ls.toString()).

Appends a string-based representation of the specified list to the specified string buffer.

Parameters:
sb - String buffer to which the representation is appended.
ls - List to append as a string.

setToStringBuilder

@Deprecated
public static void setToStringBuilder(StringBuilder sb,
                                                 Set<?> c)
Deprecated. Use sb.append(c.toString()) instead.

Appends a string-based representation of the specified set to the specified string buffer.

Parameters:
sb - String buffer to which the representation is appended.
c - Set to append as a string.

elementsToStringBuilder

@Deprecated
public static void elementsToStringBuilder(StringBuilder sb,
                                                      Collection<?> c)
Deprecated. Use sb.append(c.toString()) instead.

Appends a string-based representation of the specified colleciton to the specified string buffer.

Parameters:
sb - String buffer to which the representation is appended.
c - Collection to append as a string.

compare

@Deprecated
public static <E> int compare(E e1,
                                         E e2,
                                         Comparator<? super E> comparator)
Deprecated. Implement directly using the comparator or objects.

Compare the first objec to the second using the specified comparator if it is non-null, or by using their natural order.

Type Parameters:
E - type of objects being compared
Parameters:
e1 - First object.
e2 - Second object.
comparator - Comparator for objects, or null
Throws:
ClassCastException - If the comparator is null and the object e1 is not an instance of Comparable<? super E>.