Collections Class Reference

#include <coherence/util/Collections.hpp>

List of all members.


Detailed Description

This class consists exclusively of static methods that operate on or return collections.

Author:
tb 2008.04.04

Static Public Member Functions

static void sort (List::Handle hList)
 Sorts the specified list into ascending order, according to the natural ordering of its elements.
static void sort (List::Handle hList, Comparator::Handle hComparator)
 Sorts the specified list according to the order induced by the specified comparator.
static Set::View singleton (Object::Holder ohElement)
 Returns an immutable set containing only the specified object.
static List::View singletonList (Object::Holder ohElement)
 Returns an immutable list containing only the specified object.
static Map::View singletonMap (Object::Holder ohKey, Object::Holder ohValue)
 Returns an immutable map, mapping only the specified key to the specified value.
static Collection::Handle unmodifiableCollection (Collection::View vCollection)
 Returns an unmodifiable view of the specified collection.
static Set::Handle unmodifiableSet (Set::View vSet)
 Returns an unmodifiable view of the specified set.
static Set::View emptySet ()
 Returns an unmodifiable view of an empty set.
static Map::View emptyMap ()
 Returns an unmodifiable view of an empty map.
static void toStream (std::ostream &out, Collection::View vCol)
 Write out the contents of a Collection.
static void toStream (std::ostream &out, Map::Entry::View vEntry)
 Write out the contents of a Entry.

Member Function Documentation

static void sort ( List::Handle  hList  )  [static]

Sorts the specified list into ascending order, according to the natural ordering of its elements.

All elements in the list must implement the Comparable interface. Furthermore, all elements in the list must be mutually comparable.

This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

The specified list must be modifiable, but need not be resizable.

Parameters:
hList the list to be sorted
Exceptions:
ClassCastException if the list contains elements that are not mutually comparable
UnsupportedOperationException if the specified list's list-iterator does not support the set operation

static void sort ( List::Handle  hList,
Comparator::Handle  hComparator 
) [static]

Sorts the specified list according to the order induced by the specified comparator.

All elements in the list must be mutually comparable using the specified comparator

This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.

The specified list must be modifiable, but need not be resizable.

Parameters:
hList the list to be sorted.
hComparator the comparator to determine the order of the list. A null value indicates that the elements' natural ordering should be used.
Exceptions:
ClassCastException if the list contains elements that are not mutually comparable using the specified comparator.
UnsupportedOperationException if the specified list's list-iterator does not support the set operation.

static Set::View singleton ( Object::Holder  ohElement  )  [static]

Returns an immutable set containing only the specified object.

Parameters:
ohElement the sole object to be stored in the returned set
Returns:
an immutable set containing only the specified object

static List::View singletonList ( Object::Holder  ohElement  )  [static]

Returns an immutable list containing only the specified object.

Parameters:
ohElement the sole object to be stored in the returned list
Returns:
an immutable list containing only the specified object

static Map::View singletonMap ( Object::Holder  ohKey,
Object::Holder  ohValue 
) [static]

Returns an immutable map, mapping only the specified key to the specified value.

Parameters:
ohKey the sole key to be stored in the returned map
ohValue the value to which the returned map maps key
Returns:
an immutable map containing only the specified key-value mapping

static Collection::Handle unmodifiableCollection ( Collection::View  vCollection  )  [static]

Returns an unmodifiable view of the specified collection.

This method allows modules to provide users with "read-only" access to internal collections. Query operations on the returned collection "read through" to the specified collection, and attempts to modify the returned collection, whether direct or via its iterator, result in an UnsupportedOperationException.

The returned collection does not pass the hashCode and equals operations through to the backing collection, but relies on Object's equals and hashCode methods. This is necessary to preserve the contracts of these operations in the case that the backing collection is a set or a list.

Parameters:
vCollection the collection for which an unmodifiable view is to be returned.
Returns:
an unmodifiable view of the specified collection.

static Set::Handle unmodifiableSet ( Set::View  vSet  )  [static]

Returns an unmodifiable view of the specified set.

This method allows modules to provide users with "read-only" access to internal sets. Query operations on the returned set "read through" to the specified set, and attempts to modify the returned set, whether direct or via its iterator, result in an UnsupportedOperationException.

Parameters:
vSet the set for which an unmodifiable view is to be returned.
Returns:
an unmodifiable view of the specified set.

static Set::View emptySet (  )  [static]

Returns an unmodifiable view of an empty set.

Returns:
an unmodifiable view of an empty set.

static Map::View emptyMap (  )  [static]

Returns an unmodifiable view of an empty map.

Returns:
an unmodifiable view of an empty map.

static void toStream ( std::ostream &  out,
Collection::View  vCol 
) [static]

Write out the contents of a Collection.

Parameters:
out the stream to write the Collection to
vCol the Collection to write

static void toStream ( std::ostream &  out,
Map::Entry::View  vEntry 
) [static]

Write out the contents of a Entry.

Parameters:
out the stream to write the Entry to
vEntry the Entry to write


The documentation for this class was generated from the following file: Copyright (c) 2000-2008 Oracle. All rights reserved.