Oracle Coherence for C++ API


TypedCollections Class Reference

#include <coherence/util/TypedCollections.hpp>

Detailed Description

A collection of wrapper classes which expose an underlying collection's contents as explicit types rather then just as Objects.

Essentially these are auto-casting collections.

Each typed collection is templated based on one or more handle types to a const coherence::lang::Object Object. For instance: TypedCollection<String::View> or TypedMap<String::View, Integer32::View>

Alternate handle types may also be used for added functionality, for example: TypedMap<String::View, BoxHandle<const Integer32> > produces a TypedMap which will auto-box the supplied values to Integer32, making statements such as hMap->put("abc", 456) possible.

These typed wrappers only provide a convenience over the underlying collection. Thus they cannot guarantee that external usage of the the underlying collection will not violate the restrictions imposed by the wrapper. For instance Objects of a type other then those specified by this template may exist within the collection. Any retrieval of those elements from the wrapper will result in ClassCastException. External usage is possible anytime the typed wrapper is passed by its inherited collection interface, i.e. passing a TypedMap as a plain Map.

Member functions which take no input parameters cannot have their return type changed. Instead there will be an auxiliary function with the same name plus a "Typed" suffix, e.g. TypedMap::keySetTyped().

Example usage:

 typedef TypedCollections::TypedMap<String::View, Integer32::Handle> StringIntMap;
 StringIntMap::Handle hMap = StringIntMap::create(HashMap::create());

 hMap->put("abc", Integer32::create(123));  // String's auto-boxing is utilized
 Integer32::Handle hInt = hMap->get("abc"); // no cast of return type required

mf 2007.07.05


class  TypedCollection
 Typed wrapper over Collection interface. More...
class  TypedEntry
 Typed wrapper over Map::Entry interface. More...
class  TypedIterator
 Typed wrapper over Iterator interface. More...
class  TypedList
 Typed wrapper over List interface. More...
class  TypedListIterator
 Typed wrapper over ListIterator interface. More...
class  TypedMap
 Typed wrapper over Map interface. More...
class  TypedSet
 Typed wrapper over Set interface. More...

The documentation for this class was generated from the following file:
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.