Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

coherence/util/TypedCollections.hpp

00001 /*
00002 * TypedCollections.hpp
00003 *
00004 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_TYPED_COLLECTIONS_HPP
00017 #define COH_TYPED_COLLECTIONS_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Collection.hpp"
00022 #include "coherence/util/Converter.hpp"
00023 #include "coherence/util/ConverterCollections.hpp"
00024 #include "coherence/util/Iterator.hpp"
00025 #include "coherence/util/List.hpp"
00026 #include "coherence/util/Map.hpp"
00027 #include "coherence/util/Set.hpp"
00028 #include "coherence/util/WrapperCollections.hpp"
00029 
00030 COH_OPEN_NAMESPACE2(coherence,util)
00031 
00032 
00033 /**
00034 * A collection of wrapper classes which expose an underlying collection's
00035 * contents as explicit types rather then just as Objects.  Essentially these
00036 * are auto-casting collections.
00037 *
00038 * Each typed collection is templated based on one or more handle types
00039 * to a const coherence::lang::Object Object. For instance:
00040 * <tt>TypedCollection<String::View></tt> or
00041 * <tt>TypedMap<String::View, Integer32::View></tt>
00042 *
00043 * Alternate handle types may also be used for added functionality,
00044 * for example: <tt>TypedMap<String::View, BoxHandle<const Integer32> ></tt>
00045 * produces a TypedMap which will auto-box the supplied values to Integer32,
00046 * making statements such as <tt>hMap->put("abc", 456)</tt> possible.
00047 *
00048 * These typed wrappers only provide a convenience over the underlying
00049 * collection. Thus they cannot guarantee that external usage of the
00050 * the underlying collection will not violate the restrictions imposed by the
00051 * wrapper. For instance Objects of a type other then those specified by
00052 * this template may exist within the collection.  Any retrieval of those
00053 * elements from the wrapper will result in ClassCastException.
00054 * External usage is possible anytime the typed wrapper is passed by its
00055 * inherited collection interface, i.e. passing a TypedMap as a plain Map.
00056 *
00057 * Member functions which take no input parameters cannot have their return
00058 * type changed. Instead there will be an auxiliary function with the same name
00059 * plus a "Typed" suffix, e.g. TypedMap::keySetTyped().
00060 *
00061 * Example usage:
00062 * @code
00063 * typedef TypedCollections::TypedMap<String::View, Integer32::Handle> StringIntMap;
00064 * StringIntMap::Handle hMap = StringIntMap::create(HashMap::create());
00065 *
00066 * hMap->put("abc", Integer32::create(123));  // String's auto-boxing is utilized
00067 * Integer32::Handle hInt = hMap->get("abc"); // no cast of return type required
00068 * @endcode
00069 *
00070 * @author mf  2007.07.05
00071 */
00072 class COH_EXPORT TypedCollections
00073     {
00074     // ----- inner class: TypedIterator -------------------------------------
00075 
00076     public:
00077         /**
00078         * Typed wrapper over Iterator interface.
00079         */
00080         template<class T>
00081         class TypedIterator
00082             : public cloneable_spec<TypedIterator<T>,
00083                 extends<WrapperCollections::AbstractWrapperIterator> >
00084             {
00085             friend class factory<TypedIterator<T> >;
00086             typedef typename TypedIterator::super super;
00087 
00088             // ----- typedefs -------------------------------------------
00089 
00090             public:
00091                 /**
00092                 * The type of the handles returned by this iterator,
00093                 * e.g. String::View.
00094                 */
00095                 typedef T ValueType;
00096 
00097 
00098             // ----- constructors ---------------------------------------
00099 
00100             protected:
00101                 /**
00102                 * Create a new TypedIterator over the given Iterator.
00103                 *
00104                 * @param hIterDelegate a general "Object" Iterator to wrap
00105                 *        around
00106                 */
00107                 TypedIterator(Iterator::Handle hIterDelegate)
00108                     : super(hIterDelegate)
00109                     {
00110                     }
00111 
00112                 /**
00113                 * Copy constructor
00114                 */
00115                 TypedIterator(const TypedIterator& that)
00116                     : super(that)
00117                     {
00118                     }
00119 
00120             // ----- TypedIterator interface ----------------------------
00121 
00122             public:
00123                 /**
00124                 * The typed version of the method Iterator::next. Return the
00125                 * next element in the iteration.
00126                 *
00127                 * @return the next element in the iteration.
00128                 *
00129                 * @throws coherence::lang::NoSuchElementException
00130                 *         if iteration has no more elements.
00131                 * @throws ClassCastException
00132                 *         if the typed collection is broken by external usage
00133                 */
00134                 virtual ValueType nextTyped()
00135                     {
00136                     return cast<ValueType>(super::next());
00137                     }
00138             };
00139 
00140 
00141     // ----- inner class: TypedListIterator ---------------------------------
00142 
00143     public:
00144         /**
00145         * Typed wrapper over ListIterator interface.
00146         */
00147         template<class T>
00148         class TypedListIterator
00149             : public cloneable_spec<TypedListIterator<T>,
00150                 extends<WrapperCollections::AbstractWrapperListIterator> >
00151             {
00152             friend class factory<TypedListIterator<T> >;
00153             typedef typename TypedListIterator::super super;
00154 
00155             // ----- typedefs -------------------------------------------
00156 
00157             public:
00158                 /**
00159                 * The type of the handles returned by this iterator,
00160                 * e.g. String::View.
00161                 */
00162                 typedef T ValueType;
00163 
00164 
00165             // ----- constructors ---------------------------------------
00166 
00167             protected:
00168                 /**
00169                 * Create a new TypedListIterator over the given ListIterator.
00170                 *
00171                 * @param hIterDelegate a general "Object" Iterator to wrap
00172                 *        around
00173                 */
00174                 TypedListIterator(ListIterator::Handle hIterDelegate)
00175                     : super(hIterDelegate)
00176                     {
00177                     }
00178 
00179                 /**
00180                 * Copy constructor.
00181                 */
00182                 TypedListIterator(const TypedListIterator& that)
00183                     : super(that)
00184                     {
00185                     }
00186 
00187 
00188             // ----- TypedIterator interface ----------------------------
00189 
00190             public:
00191                 /**
00192                 * The typed version of the method Iterator::next. Return the
00193                 * next element in the iteration.
00194                 *
00195                 * @return the next element in the iteration.
00196                 *
00197                 * @throws coherence::lang::NoSuchElementException
00198                 *         if iteration has no more elements.
00199                 * @throws ClassCastException
00200                 *         if the typed collection is broken by external usage
00201                 */
00202                 virtual ValueType nextTyped()
00203                     {
00204                     return cast<ValueType>(super::next());
00205                     }
00206 
00207 
00208             // ----- ListIterator interface -----------------------------
00209 
00210             public:
00211                 /**
00212                 * The typed version of the method ListIterator::previous.
00213                 * <p> Return the previous element in the iteration.
00214                 *
00215                 * @return the previous element in the iteration.
00216                 *
00217                 * @throws coherence::lang::NoSuchElementException
00218                 *         if iteration has no previous elements.
00219                 * @throws ClassCastException
00220                 *         if the typed collection is broken by external usage
00221                 */
00222                 virtual ValueType previousTyped()
00223                     {
00224                     return cast<ValueType>(super::previous());
00225                     }
00226 
00227 
00228             // ----- ListMuterator interface ----------------------------
00229 
00230             public:
00231                 /**
00232                 * The typed version of the method ListIterator::add.
00233                 * <p>
00234                 * Insert the specified element immediately before the element
00235                 * to be returned from the next call to the next() method. A
00236                 * subsequent call to next() will not return the added
00237                 * element, while a call to previous() would return the added
00238                 * element.
00239                 *
00240                 * @param v  the element to add
00241                 *
00242                 * @throws UnsupportedOperationException if addition is not
00243                 *         supported
00244                 */
00245                 virtual void add(ValueType v)
00246                     {
00247                     super::add(v);
00248                     }
00249 
00250                 using super::add;
00251 
00252                 /**
00253                 * The typed version of the method ListIterator::set.
00254                 * <p>
00255                 * Replace the last element returned by next() or previous() with
00256                 * the specified element.
00257                 *
00258                 * @param oh  the element to store
00259                 *
00260                 * @throws UnsupportedOperationException if set is not supported
00261                 */
00262                 virtual void set(ValueType v)
00263                     {
00264                     super::set(v);
00265                     }
00266 
00267                 using super::set;
00268             };
00269 
00270 
00271         // ---- inner class: TypedCollection --------------------------------
00272 
00273         /**
00274         * Typed wrapper over Collection interface.
00275         */
00276         template<class T>
00277         class TypedCollection
00278             : public cloneable_spec<TypedCollection<T>,
00279                 extends<WrapperCollections::AbstractWrapperCollection> >
00280             {
00281             friend class factory<TypedCollection<T> >;
00282             typedef typename TypedCollection::this_spec super;
00283 
00284             // ----- typedefs -------------------------------------------
00285 
00286             public:
00287                 /**
00288                 * The type of the objects stored in this collection, that
00289                 * e.g. String::View.
00290                 */
00291                 typedef T ValueType;
00292 
00293                 /**
00294                 * The type of the iterator over this collection.
00295                 */
00296                 typedef TypedIterator<T> Iterator;
00297 
00298 
00299             // ----- constructors ---------------------------------------
00300 
00301             protected:
00302                 /**
00303                 * Create a new TypedCollection over the given Collection.
00304                 *
00305                 * @param ohCollDelegate  the Collection to delegate to
00306                 */
00307                 TypedCollection(Collection::Holder ohCollDelegate)
00308                     : super(ohCollDelegate)
00309                     {
00310                     }
00311 
00312                 /**
00313                 * Copy constructor.
00314                 */
00315                 TypedCollection(const TypedCollection& that)
00316                     : super(that)
00317                     {
00318                     }
00319 
00320 
00321             // ----- TypedCollection interface --------------------------
00322 
00323             public:
00324                 /**
00325                 * The typed version of the method Collection::iterator.
00326                 * Return a handle to an TypedIterator over the elements in
00327                 * this collection.
00328                 *
00329                 * @return a TypedIterator over the elements in this
00330                 *         collection
00331                 */
00332                 virtual typename TypedCollection::Iterator::Handle iteratorTyped() const
00333                     {
00334                     return TypedCollection::Iterator::create(super::iterator());
00335                     }
00336 
00337                 /**
00338                 * The typed version of the method Collection::iterator.
00339                 * Return a handle to an TypedIterator over the elements in
00340                 * this collection.
00341                 *
00342                 * @return a TypedIterator over the elements in this
00343                 *         collection
00344                 */
00345                 virtual typename TypedCollection::Iterator::Handle iteratorTyped()
00346                     {
00347                     return TypedCollection::Iterator::create(super::iterator());
00348                     }
00349 
00350                 /**
00351                 * {@inheritDoc}
00352                 */
00353                 virtual coherence::util::Iterator::Handle iterator() const
00354                     {
00355                     return iteratorTyped();
00356                     }
00357 
00358                 /**
00359                 * {@inheritDoc}
00360                 */
00361                 virtual coherence::util::Muterator::Handle iterator()
00362                     {
00363                     return iteratorTyped();
00364                     }
00365 
00366                 /**
00367                 * {@inheritDoc}
00368                 */
00369                 using super::contains;
00370 
00371                 /**
00372                 * The typed version of the method Collection::contains.
00373                 *
00374                 * Return true if this collection contains the specified
00375                 * element.
00376                 *
00377                 * @param v element whose presence in this collection is to
00378                 *          be tested
00379                 *
00380                 * @return true if this collection contains the specified
00381                 *         element
00382                 */
00383                 virtual bool contains(ValueType v) const
00384                     {
00385                     return super::contains(v);
00386                     }
00387 
00388                 /**
00389                 * {@inheritDoc}
00390                 */
00391                 using super::add;
00392 
00393                 /**
00394                 * The typed version of the method Collection::add. Ensure
00395                 * that this collection contains the specified element.
00396                 *
00397                 * @param v element whose presence in this collection is to be
00398                 *          ensured
00399                 *
00400                 * @return true if this collection changed as a result of the
00401                 *         call
00402                 *
00403                 * @throws coherence::lang::UnsupportedOperationException
00404                 *         if the #add() operation is not supported by this
00405                 *         collection
00406                 */
00407                 virtual bool add(ValueType v)
00408                     {
00409                     return super::add(v);
00410                     }
00411 
00412                 /**
00413                 * {@inheritDoc}
00414                 */
00415                 using super::remove;
00416 
00417                 /**
00418                 * The typed version of the method Collection::remove. Remove
00419                 * a single instance of the specified element from this
00420                 * collection, if it is present.
00421                 *
00422                 * @param v element to be removed from this collection, if
00423                 *          present
00424                 *
00425                 * @return true if this collection changed as a result of
00426                 *         the call
00427                 *
00428                 * @throws coherence::lang::UnsupportedOperationException
00429                 *         if the #remove() operation is not supported by this
00430                 *         collection
00431                 */
00432                 virtual bool remove(ValueType v)
00433                     {
00434                     return super::remove(v);
00435                     }
00436 
00437                 /**
00438                 * {@inheritDoc}
00439                 */
00440                 using super::addAll;
00441 
00442                 /**
00443                 * The typed version of the method Collection::addAll.
00444                 *
00445                 * Add all of the elements in the specified collection to this
00446                 * collection.
00447                 *
00448                 * @param vtc TypedCollection of elements to be inserted into
00449                 *            this collection
00450                 *
00451                 * @return true if this collection changed as a result of
00452                 *         the call
00453                 *
00454                 * @throws coherence::lang::NullPointerException
00455                 *         if the specified collection is NULL
00456                 * @throws coherence::lang::UnsupportedOperationException
00457                 *         if the #add() operation is not supported by this
00458                 *         collection
00459                 */
00460                 virtual bool addAll(typename TypedCollection::View vtc)
00461                     {
00462                     return super::addAll(vtc);
00463                     }
00464 
00465                 /**
00466                 * {@inheritDoc}
00467                 */
00468                 using super::removeAll;
00469 
00470                 /**
00471                 * The typed version of the method Collection::removeAll.
00472                 *
00473                 * Remove all this collection's elements that are also
00474                 * contained in the specified typed collection.
00475                 *
00476                 * @param vtc elements to be removed from this collection
00477                 *
00478                 * @return true if this collection changed as a result of
00479                 *         the call
00480                 *
00481                 * @throws coherence::lang::NullPointerException
00482                 *         if the specified collection is NULL
00483                 * @throws coherence::lang::UnsupportedOperationException
00484                 *         if the #remove() operation is not supported by this
00485                 *         collection
00486                 */
00487                 virtual bool removeAll(typename TypedCollection::View vtc)
00488                     {
00489                     return super::removeAll(vtc);
00490                     }
00491 
00492                 /**
00493                 * {@inheritDoc}
00494                 */
00495                 using super::retainAll;
00496 
00497                 /**
00498                 * The typed version of the method Collection::retainAll.
00499                 *
00500                 * Retain only the elements in this collection that are
00501                 * contained in the specified typed collection.
00502                 *
00503                 * @param vtc elements to be retained in this collection
00504                 *
00505                 * @return true if this collection changed as a result of
00506                 *         the call
00507                 *
00508                 * @throws coherence::lang::NullPointerException
00509                 *         if the specified collection is NULL
00510                 * @throws coherence::lang::UnsupportedOperationException
00511                 *         if the #remove() operation is not supported by this
00512                 *         collection
00513                 */
00514                 virtual bool retainAll(typename TypedCollection::View vtc)
00515                     {
00516                     return super::retainAll(vtc);
00517                     }
00518             };
00519 
00520 
00521         // ----- inner class: TypedSet --------------------------------------
00522 
00523         /**
00524         * Typed wrapper over Set interface.
00525         */
00526         template<class T>
00527         class TypedSet
00528             : public cloneable_spec<TypedSet<T>,
00529                 extends<WrapperCollections::AbstractWrapperSet> >
00530             {
00531             friend class factory<TypedSet<T> >;
00532             typedef typename TypedSet::super super;
00533 
00534             // ----- typedefs -------------------------------------------
00535 
00536             public:
00537                 /**
00538                 * The type of the objects stored in this set, that
00539                 * e.g. String::View.
00540                 */
00541                 typedef T ValueType;
00542 
00543                 /**
00544                 * The type of the iterator over this set.
00545                 */
00546                 typedef TypedIterator<T> Iterator;
00547 
00548 
00549             // ----- constructors ---------------------------------------
00550 
00551             protected:
00552                 /**
00553                 * Create a new TypedSet over the given Set.
00554                 *
00555                 * @param ohSetDelegate  the Set to delegate to
00556                 */
00557                 TypedSet(Set::Holder ohSetDelegate)
00558                     : super(ohSetDelegate)
00559                     {
00560                     }
00561 
00562                 /**
00563                 * Copy constructor.
00564                 */
00565                 TypedSet(const TypedSet& that)
00566                     : super(that)
00567                     {
00568                     }
00569 
00570 
00571             // ----- TypedSet interface ---------------------------------
00572 
00573             public:
00574                 /**
00575                 * {@inheritDoc}
00576                 */
00577                 using super::contains;
00578 
00579                 /**
00580                 * The typed version of the method Collection::contains.
00581                 * Return true if this set contains the specified element.
00582                 *
00583                 * @param v element whose presence in this set is to be tested
00584                 *
00585                 * @return true if this collection contains the specified
00586                 *         element
00587                 */
00588                 virtual bool contains(ValueType v) const
00589                     {
00590                     return super::contains(v);
00591                     }
00592 
00593                 /**
00594                 * The typed version of the method Collection::iterator.
00595                 * Return a handle to an TypedIterator over the elements in
00596                 * this set.
00597                 *
00598                 * @return a TypedIterator over the elements in this
00599                 *         set
00600                 */
00601                 virtual typename TypedSet::Iterator::Handle iteratorTyped() const
00602                     {
00603                     return TypedSet::Iterator::create(super::iterator());
00604                     }
00605 
00606                 /**
00607                 * The typed version of the method Collection::iterator.
00608                 * Return a handle to an TypedIterator over the elements in
00609                 * this set.
00610                 *
00611                 * @return a TypedIterator over the elements in this
00612                 *         set
00613                 */
00614                 virtual typename TypedSet::Iterator::Handle iteratorTyped()
00615                     {
00616                     return TypedSet::Iterator::create(super::iterator());
00617                     }
00618 
00619                 /**
00620                 * {@inheritDoc}
00621                 */
00622                 virtual coherence::util::Iterator::Handle iterator() const
00623                     {
00624                     return iteratorTyped();
00625                     }
00626 
00627                 /**
00628                 * {@inheritDoc}
00629                 */
00630                 virtual coherence::util::Muterator::Handle iterator()
00631                     {
00632                     return iteratorTyped();
00633                     }
00634 
00635                 /**
00636                 * {@inheritDoc}
00637                 */
00638                 using super::add;
00639 
00640                 /**
00641                 * The typed version of the method Set::add. Add the specified
00642                 * element to this set if it is not already present.
00643                 *
00644                 * @param v element to be added to this set.
00645                 *
00646                 * @return true if this set changed as a result of the
00647                 *         call
00648                 *
00649                 * @throws coherence::lang::UnsupportedOperationException
00650                 *         if the #add() operation is not supported by this
00651                 *         set
00652                 */
00653                 virtual bool add(ValueType v)
00654                     {
00655                     return super::add(v);
00656                     }
00657 
00658                 /**
00659                 * {@inheritDoc}
00660                 */
00661                 using super::remove;
00662 
00663                 /**
00664                 * The typed version of the method Collection::remove. Remove
00665                 * the specified element from this set, if it is present.
00666                 *
00667                 * @param v element to be removed from this set, if present
00668                 *
00669                 * @return true if this set changed as a result of
00670                 *         the call
00671                 *
00672                 * @throws coherence::lang::UnsupportedOperationException
00673                 *         if the #remove() operation is not supported by this
00674                 *         set
00675                 */
00676                 virtual bool remove(ValueType v)
00677                     {
00678                     return super::remove(v);
00679                     }
00680 
00681                 /**
00682                 * {@inheritDoc}
00683                 */
00684                 using super::addAll;
00685 
00686 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
00687                 /**
00688                 * The typed version of the method Collection::addAll.
00689                 *
00690                 * Add all of the elements in the specified TypedCollection to
00691                 * this set.
00692                 *
00693                 * @param vtc TypedCollection of elements to be inserted into
00694                 *            this set
00695                 *
00696                 * @return true if this set changed as a result of the call
00697                 *
00698                 * @throws coherence::lang::NullPointerException
00699                 *         if the specified collection is NULL
00700                 * @throws coherence::lang::UnsupportedOperationException
00701                 *         if the #add() operation is not supported by this set
00702                 */
00703                 virtual bool addAll(typename
00704                                 TypedCollection<ValueType>::View vtc)
00705                     {
00706                     return super::addAll(vtc);
00707                     }
00708 
00709                 /**
00710                 * The typed version of the method Collection::addAll.
00711                 *
00712                 * Add all of the elements in the specified TypedCollection to
00713                 * this set.
00714                 *
00715                 * @param htc TypedCollection of elements to be inserted into
00716                 *            this set
00717                 *
00718                 * @return true if this set changed as a result of the call
00719                 *
00720                 * @throws coherence::lang::NullPointerException
00721                 *         if the specified collection is NULL
00722                 * @throws coherence::lang::UnsupportedOperationException
00723                 *         if the #add() operation is not supported by this set
00724                 */
00725                 virtual bool addAll(typename
00726                                 TypedCollection<ValueType>::Handle htc)
00727                     {
00728                     return super::addAll(htc);
00729                     }
00730 #endif
00731 
00732                 /**
00733                 * The typed version of the method Collection::addAll.
00734                 *
00735                 * Add all of the elements in the specified TypedSet to this
00736                 * set.
00737                 *
00738                 * @param vts TypedSet of elements to be inserted into
00739                 *            this set
00740                 *
00741                 * @return true if this set changed as a result of the call
00742                 *
00743                 * @throws coherence::lang::NullPointerException
00744                 *         if the specified collection is NULL
00745                 * @throws coherence::lang::UnsupportedOperationException
00746                 *         if the #add() operation is not supported by this set
00747                 */
00748                 virtual bool addAll(typename TypedSet<ValueType>::View vts)
00749                     {
00750                     return super::addAll(vts);
00751                     }
00752 
00753                 /**
00754                 * The typed version of the method Collection::addAll.
00755                 *
00756                 * Add all of the elements in the specified TypedSet to this
00757                 * set.
00758                 *
00759                 * @param hts TypedSet of elements to be inserted into
00760                 *            this set
00761                 *
00762                 * @return true if this set changed as a result of the call
00763                 *
00764                 * @throws coherence::lang::NullPointerException
00765                 *         if the specified collection is NULL
00766                 * @throws coherence::lang::UnsupportedOperationException
00767                 *         if the #add() operation is not supported by this set
00768                 */
00769                 virtual bool addAll(typename TypedSet<ValueType>::Handle hts)
00770                     {
00771                     return super::addAll(hts);
00772                     }
00773 
00774                 /**
00775                 * {@inheritDoc}
00776                 */
00777                 using super::removeAll;
00778 
00779 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
00780                 /**
00781                 * The typed version of the method Collection::removeAll.
00782                 *
00783                 * Remove all this set's elements that are also contained in
00784                 * the specified typed collection.
00785                 *
00786                 * @param vtc elements to be removed from this set
00787                 *
00788                 * @return true if this set changed as a result of
00789                 *         the call
00790                 *
00791                 * @throws coherence::lang::NullPointerException
00792                 *         if the specified collection is NULL
00793                 * @throws coherence::lang::UnsupportedOperationException
00794                 *         if the #remove() operation is not supported by this
00795                 *         set
00796                 */
00797                 virtual bool removeAll(typename
00798                                 TypedCollection<ValueType>::View vtc)
00799                     {
00800                     return super::removeAll(vtc);
00801                     }
00802 
00803                 /**
00804                 * The typed version of the method Collection::removeAll.
00805                 *
00806                 * Remove all this set's elements that are also contained in
00807                 * the specified typed collection.
00808                 *
00809                 * @param htc elements to be removed from this set
00810                 *
00811                 * @return true if this set changed as a result of
00812                 *         the call
00813                 *
00814                 * @throws coherence::lang::NullPointerException
00815                 *         if the specified collection is NULL
00816                 * @throws coherence::lang::UnsupportedOperationException
00817                 *         if the #remove() operation is not supported by this
00818                 *         set
00819                 */
00820                 virtual bool removeAll(typename
00821                                 TypedCollection<ValueType>::Handle htc)
00822                     {
00823                     return super::removeAll(htc);
00824                     }
00825 #endif
00826 
00827                 /**
00828                 * The typed version of the method Collection::removeAll.
00829                 *
00830                 * Remove all this set's elements that are also contained in
00831                 * the specified typed set.
00832                 *
00833                 * @param vts elements to be removed from this set
00834                 *
00835                 * @return true if this set changed as a result of
00836                 *         the call
00837                 *
00838                 * @throws coherence::lang::NullPointerException
00839                 *         if the specified collection is NULL
00840                 * @throws coherence::lang::UnsupportedOperationException
00841                 *         if the #remove() operation is not supported by this
00842                 *         set
00843                 */
00844                 virtual bool removeAll(typename
00845                                 TypedSet<ValueType>::View vts)
00846                     {
00847                     return super::removeAll(vts);
00848                     }
00849 
00850                 /**
00851                 * The typed version of the method Collection::removeAll.
00852                 *
00853                 * Remove all this set's elements that are also contained in
00854                 * the specified typed set.
00855                 *
00856                 * @param hts elements to be removed from this set
00857                 *
00858                 * @return true if this set changed as a result of
00859                 *         the call
00860                 *
00861                 * @throws coherence::lang::NullPointerException
00862                 *         if the specified collection is NULL
00863                 * @throws coherence::lang::UnsupportedOperationException
00864                 *         if the #remove() operation is not supported by this
00865                 *         set
00866                 */
00867                 virtual bool removeAll(typename
00868                                 TypedSet<ValueType>::Handle hts)
00869                     {
00870                     return super::removeAll(hts);
00871                     }
00872 
00873                 /**
00874                 * {@inheritDoc}
00875                 */
00876                 using super::retainAll;
00877 
00878 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
00879                 /**
00880                 * The typed version of the method Collection::retainAll.
00881                 *
00882                 * Retain only the elements in this set that are
00883                 * contained in the specified typed collection.
00884                 *
00885                 * @param vtc elements to be retained in this set
00886                 *
00887                 * @return true if this set changed as a result of
00888                 *         the call
00889                 *
00890                 * @throws coherence::lang::NullPointerException
00891                 *         if the specified collection is NULL
00892                 * @throws coherence::lang::UnsupportedOperationException
00893                 *         if the #remove() operation is not supported by this
00894                 *         set
00895                 */
00896                 virtual bool retainAll(typename
00897                                 TypedCollection<ValueType>::View vtc)
00898                     {
00899                     return super::retainAll(vtc);
00900                     }
00901 
00902                 /**
00903                 * The typed version of the method Collection::retainAll.
00904                 *
00905                 * Retain only the elements in this set that are
00906                 * contained in the specified typed collection.
00907                 *
00908                 * @param htc elements to be retained in this set
00909                 *
00910                 * @return true if this set changed as a result of
00911                 *         the call
00912                 *
00913                 * @throws coherence::lang::NullPointerException
00914                 *         if the specified collection is NULL
00915                 * @throws coherence::lang::UnsupportedOperationException
00916                 *         if the #remove() operation is not supported by this
00917                 *         set
00918                 */
00919                 virtual bool retainAll(typename
00920                                 TypedCollection<ValueType>::Handle htc)
00921                     {
00922                     return super::retainAll(htc);
00923                     }
00924 #endif
00925 
00926                 /**
00927                 * The typed version of the method Collection::retainAll.
00928                 *
00929                 * Retain only the elements in this set that are
00930                 * contained in the specified typed set.
00931                 *
00932                 * @param vts elements to be retained in this set
00933                 *
00934                 * @return true if this set changed as a result of
00935                 *         the call
00936                 *
00937                 * @throws coherence::lang::NullPointerException
00938                 *         if the specified collection is NULL
00939                 * @throws coherence::lang::UnsupportedOperationException
00940                 *         if the #remove() operation is not supported by this
00941                 *         set
00942                 */
00943                 virtual bool retainAll(typename
00944                                 TypedSet<ValueType>::View vts)
00945                     {
00946                     return super::retainAll(vts);
00947                     }
00948 
00949                 /**
00950                 * The typed version of the method Collection::retainAll.
00951                 *
00952                 * Retain only the elements in this set that are
00953                 * contained in the specified typed set.
00954                 *
00955                 * @param hts elements to be retained in this set
00956                 *
00957                 * @return true if this set changed as a result of
00958                 *         the call
00959                 *
00960                 * @throws coherence::lang::NullPointerException
00961                 *         if the specified collection is NULL
00962                 * @throws coherence::lang::UnsupportedOperationException
00963                 *         if the #remove() operation is not supported by this
00964                 *         set
00965                 */
00966                 virtual bool retainAll(typename
00967                                 TypedSet<ValueType>::Handle hts)
00968                     {
00969                     return super::retainAll(hts);
00970                     }
00971 
00972                 /**
00973                 * Convert a TypedSet to a TypedCollection, wrapping the same
00974                 * underlying Collection::Handle.
00975                 *
00976                 * @return a handle to the new TypedCollection
00977                 */
00978                 virtual typename TypedCollection<ValueType>::Handle
00979                     asTypedCollection()
00980                     {
00981                     return TypedCollection<ValueType>::create(
00982                         cast<Collection::Handle>(super::getDelegate()));
00983                     }
00984 
00985                 /**
00986                 * Convert a TypedSet to a TypedCollection, wrapping the same
00987                 * underlying Collection::View.
00988                 *
00989                 * @return a view to the new TypedCollection
00990                 */
00991                 virtual typename TypedCollection<ValueType>::View
00992                     asTypedCollection() const
00993                     {
00994                     return TypedCollection<ValueType>::create(
00995                         cast<Collection::View>(super::getDelegate()));
00996                     }
00997             };
00998 
00999 
01000         // ----- inner class: TypedEntry ------------------------------------
01001 
01002         /**
01003         * Typed wrapper over Map::Entry interface. Both key and value objects
01004         * are typed. The types of key and value may differ.
01005         */
01006         template<class K, class V>
01007         class TypedEntry
01008             : public cloneable_spec<TypedEntry<K, V>,
01009                 extends<WrapperCollections::AbstractWrapperEntry> >
01010             {
01011             friend class factory<TypedEntry<K, V> >;
01012             typedef typename TypedEntry::this_spec super;
01013 
01014             // ----- typedefs -------------------------------------------
01015 
01016             public:
01017                 /**
01018                 * The type of the keys, e.g. String::View.
01019                 */
01020                 typedef K KeyType;
01021 
01022                 /**
01023                 * The type the values, e.g. String::View.
01024                 */
01025                 typedef V ValueType;
01026 
01027 
01028             // ----- constructors ---------------------------------------
01029 
01030             protected:
01031                 /**
01032                 * Create a new TypedEntry over the given Map::Entry.
01033                 *
01034                 *
01035                 * @param ohEntryDelegate  the Entry to delegate to
01036                 */
01037                 TypedEntry(Map::Entry::Holder ohEntryDelegate)
01038                     : super(ohEntryDelegate)
01039                     {
01040                     }
01041 
01042                 /**
01043                 * Copy constructor.
01044                 */
01045                 TypedEntry(const TypedEntry& that)
01046                     : super(that)
01047                     {
01048                     }
01049 
01050 
01051             // ----- TypedEntry interface -------------------------------
01052 
01053             public:
01054                 /**
01055                 * The typed version of the method Map::Entry::getKey.
01056                 *
01057                 * Return the key corresponding to this entry.
01058                 *
01059                 * @return the key corresponding to this entry.
01060                 *
01061                 * @throws ClassCastException
01062                 *         if the typed entry is broken by external usage
01063                 */
01064                 virtual KeyType getKeyTyped() const
01065                     {
01066                     return cast<KeyType>(super::getKey());
01067                     }
01068 
01069                 /**
01070                 * The typed version of the method Map::Entry::getKey.
01071                 *
01072                 * Return the value corresponding to this entry.
01073                 *
01074                 * @return the value corresponding to this entry.
01075                 *
01076                 * @throws ClassCastException
01077                 *         if the typed entry is broken by external usage
01078                 */
01079                 virtual ValueType getValueTyped() const
01080                     {
01081                     return cast<ValueType>(super::getValue());
01082                     }
01083 
01084                 /**
01085                 * The typed version of the method Map::Entry::getKey.
01086                 *
01087                 * Return the value corresponding to this entry.
01088                 *
01089                 * @return the value corresponding to this entry.
01090                 *
01091                 * @throws ClassCastException
01092                 *         if the typed entry is broken by external usage
01093                 */
01094                 virtual ValueType getValueTyped()
01095                     {
01096                     return cast<ValueType>(super::getValue());
01097                     }
01098 
01099                 /**
01100                 * {@inheritDoc}
01101                 */
01102                 using super::setValue;
01103 
01104                 /**
01105                 * Update the value of the map entry.
01106                 *
01107                 * @param ohValue  the new value for the entry
01108                 *
01109                 * @return the prior value
01110                 */
01111                 virtual ValueType setValue(ValueType ohValue)
01112                     {
01113                     return cast<ValueType>(super::setValue(ohValue));
01114                     }
01115             };
01116 
01117 
01118         // ----- inner class: TypedMap --------------------------------------
01119 
01120         /**
01121         * Typed wrapper over Map interface.
01122         */
01123         template<class K, class V>
01124         class TypedMap
01125             : public cloneable_spec<TypedMap<K, V>,
01126                 extends<WrapperCollections::AbstractWrapperMap> >
01127             {
01128             friend class factory<TypedMap<K, V> >;
01129             typedef typename TypedMap::this_spec super;
01130 
01131             // ----- typedefs -------------------------------------------
01132 
01133             public:
01134                 /**
01135                 * The type of the map's keys, e.g. String::View.
01136                 */
01137                 typedef K KeyType;
01138 
01139                 /**
01140                 * The type of the map's values, e.g. String::View.
01141                 */
01142                 typedef V ValueType;
01143 
01144                 /**
01145                 * The type of the entries stored in this map.
01146                 */
01147                 typedef TypedEntry<KeyType, ValueType> Entry;
01148 
01149                 /**
01150                 * The type of the key set associated with this map.
01151                 */
01152                 typedef TypedSet<KeyType> KeySet;
01153 
01154                 /**
01155                 * The type of the values collection associated with this map.
01156                 */
01157                 typedef TypedCollection<ValueType> ValueCollection;
01158 
01159                 /**
01160                 * The type of the entry set associated with this map.
01161                 */
01162                 typedef TypedSet<typename Entry::View> EntrySet;
01163 
01164 
01165             // ----- inner class: EntryConverter ------------------------
01166 
01167             protected:
01168                 /**
01169                 * A converter from untyped to typed entries:
01170                 * Map::Entry -> TypedEntry
01171                 */
01172                 class EntryConverter
01173                     : public class_spec<EntryConverter,
01174                         extends<Object>,
01175                         implements<Converter> >
01176                     {
01177                     friend class factory<EntryConverter>;
01178 
01179                     // ----- constructors ---------------------------
01180 
01181                     protected:
01182                         /**
01183                         * Create new EntryConverter instance.
01184                         */
01185                         EntryConverter()
01186                             {
01187                             }
01188 
01189                         /**
01190                         * Copy constructor.
01191                         */
01192                         EntryConverter(const EntryConverter&)
01193                             {
01194                             }
01195 
01196 
01197                     // ----- Converter interface --------------------
01198 
01199                     public:
01200                         /**
01201                         * {@inheritDoc}
01202                         */
01203                         virtual Object::Holder convert(Object::Holder oh) const
01204                             {
01205                             typename Entry::View vEntry =
01206                                     cast<typename Entry::View>(oh, false);
01207                             if (vEntry == NULL)
01208                                 {
01209                                 // conversion from Map::Entry to
01210                                 // TypedMap::Entry required
01211                                 // maintain Object::Holder view/handle
01212                                 Map::Entry::Handle h =
01213                                         cast<Map::Entry::Handle>(oh, false);
01214                                 if (h == NULL)
01215                                     {
01216                                     return Entry::create(
01217                                             cast<Map::Entry::View>(oh));
01218                                     }
01219                                 return Entry::create(h);
01220                                 }
01221                             else
01222                                 {
01223                                 // no conversion necessary
01224                                 return oh;
01225                                 }
01226                             }
01227 
01228                     // ----- Object interface -----------------------
01229 
01230                     public:
01231                         /**
01232                         * {@inheritDoc}
01233                         */
01234                         virtual bool isImmutable() const
01235                             {
01236                             return true;
01237                             }
01238                     };
01239 
01240             // ----- constructors -----------------------------------
01241 
01242             protected:
01243                 /**
01244                 * Create a new TypedMap over the given Map.
01245                 *
01246                 * @param ohMapDelegate  the Map to delegate to
01247                 */
01248                 TypedMap(Map::Holder ohMapDelegate)
01249                     : super(ohMapDelegate),
01250                       f_vConverter(Object::self(), EntryConverter::create())
01251                     {
01252                     }
01253 
01254                 /**
01255                 * Copy constructor.
01256                 */
01257                 TypedMap(const TypedMap& that)
01258                     : super(that),
01259                       f_vConverter(Object::self(), EntryConverter::create())
01260                     {
01261                     }
01262 
01263 
01264             // ----- TypedMap interface -----------------------------
01265 
01266             public:
01267                 /**
01268                 * {@inheritDoc}
01269                 */
01270                 using super::containsKey;
01271 
01272                 /**
01273                 * The typed version of the method Map::containsKey.
01274                 *
01275                 * Return <tt>true</tt> if this map contains a mapping for the
01276                 * specified key.
01277                 *
01278                 * @param vKey key whose presence in this map is to be tested.
01279                 *
01280                 * @return <tt>true</tt> if this map contains a mapping for
01281                 *         the specified key.
01282                 */
01283                 virtual bool containsKey(KeyType vKey) const
01284                     {
01285                     return super::containsKey(vKey);
01286                     }
01287 
01288                 /**
01289                 * {@inheritDoc}
01290                 */
01291                 using super::containsValue;
01292 
01293                 /**
01294                 * The typed version of the method Map::containsValue.
01295                 *
01296                 * Return <tt>true</tt> if this map maps one or more keys to
01297                 * the specified value.
01298                 *
01299                 * @param ohValue value whose presence in this map is to be
01300                 *               tested.
01301                 *
01302                 * @return <tt>true</tt> if this map maps one or more keys to
01303                 *          the specified value.
01304                 */
01305                 virtual bool containsValue(ValueType ohValue) const
01306                     {
01307                     return super::containsValue(ohValue);
01308                     }
01309 
01310                 /**
01311                 * {@inheritDoc}
01312                 */
01313                 using super::get;
01314 
01315                 /**
01316                 * The typed version of the method Map::get.
01317                 *
01318                 * Return the value to which this map maps the specified key,
01319                 * if any.
01320                 *
01321                 * @param vKey key whose associated value is to be returned.
01322                 *
01323                 * @return the value to which this map maps the specified key,
01324                 *          or <tt>NULL</tt> if the map contains no mapping
01325                 *          for this key.
01326                 *
01327                 * @throws ClassCastException
01328                 *         if the typed map is broken by external usage
01329                 */
01330                 virtual ValueType get(KeyType vKey) const
01331                     {
01332                     return cast<ValueType>(super::get(vKey));
01333                     }
01334 
01335                 /**
01336                 * The typed version of the method Map::get.
01337                 *
01338                 * Return the value to which this map maps the specified key,
01339                 * if any.
01340                 *
01341                 * @param vKey key whose associated value is to be returned.
01342                 *
01343                 * @return the value to which this map maps the specified key,
01344                 *          or <tt>NULL</tt> if the map contains no mapping
01345                 *          for this key.
01346                 *
01347                 * @throws ClassCastException
01348                 *         if the typed map is broken by external usage
01349                 */
01350                 virtual ValueType get(KeyType vKey)
01351                     {
01352                     return cast<ValueType>(super::get(vKey));
01353                     }
01354 
01355                 /**
01356                 * {@inheritDoc}
01357                 */
01358                 using super::put;
01359 
01360                 /**
01361                 * The typed version of the method Map::put.
01362                 *
01363                 * Associate the specified value with the specified key in
01364                 * this map.
01365                 *
01366                 * @param vKey   key with which the specified value is to be
01367                 *               associated.
01368                 * @param ohValue value to be associated with the specified
01369                 *               key.
01370                 *
01371                 * @return previous value associated with specified key, or
01372                 *         <tt>NULL</tt> if there was no mapping for key.  A
01373                 *         <tt>NULL</tt> return can also indicate that the map
01374                 *         previously associated <tt>NULL</tt> with the
01375                 *         specified key.
01376                 *
01377                 * @throws coherence::lang::UnsupportedOperationException
01378                 *         if the #put() operation is not supported by this map
01379                 * @throws ClassCastException
01380                 *         if the typed map is broken by external usage
01381                 */
01382                 virtual ValueType put(KeyType vKey, ValueType ohValue)
01383                     {
01384                     return cast<ValueType>(super::put(vKey, ohValue));
01385                     }
01386 
01387                 /**
01388                 * {@inheritDoc}
01389                 */
01390                 using super::remove;
01391 
01392                 /**
01393                 * The typed version of the method Map::put.
01394                 *
01395                 * Remove the mapping for this key from this map if it
01396                 * is present.
01397                 *
01398                 * @param vKey key whose mapping is to be removed from
01399                 *             the map.
01400                 *
01401                 * @return previous value associated with specified key, or
01402                 *         <tt>NULL</tt> if there was no mapping for key.
01403                 *
01404                 * @throws coherence::lang::UnsupportedOperationException
01405                 *         if the #remove() operation is not supported by this
01406                 *         map
01407                 * @throws ClassCastException
01408                 *         if the typed map is broken by external usage
01409                 */
01410                 virtual ValueType remove(KeyType vKey)
01411                     {
01412                     return cast<ValueType>(super::remove(vKey));
01413                     }
01414 
01415                 /**
01416                 * {@inheritDoc}
01417                 */
01418                 using super::putAll;
01419 
01420                 /**
01421                 * The typed version of the method Map::putAll.
01422                 *
01423                 * Copy all of the mappings from the specified typed map
01424                 * to this map.
01425                 *
01426                 * @param vMap mappings to be stored in this map.
01427                 *
01428                 * @throws coherence::lang::UnsupportedOperationException
01429                 *         if the #put() operation is not supported by this
01430                 *         map
01431                 */
01432                 virtual void putAll(typename TypedMap::View vMap)
01433                     {
01434                     super::putAll(vMap);
01435                     }
01436 
01437                 /**
01438                 * The typed version of the method Map::keySet.
01439                 *
01440                 * Return a typed set view of the keys contained in this map.
01441                 *
01442                 * @return a typed set view of the keys contained in this map.
01443                 */
01444                 virtual typename KeySet::View keySetTyped() const
01445                     {
01446                     return KeySet::create(super::keySet());
01447                     }
01448 
01449                 /**
01450                 * The typed version of the method Map::keySet.
01451                 *
01452                 * Return a typed set view of the keys contained in this map.
01453                 *
01454                 * @return a typed set view of the keys contained in this map.
01455                 */
01456                 virtual typename KeySet::Handle keySetTyped()
01457                     {
01458                     return KeySet::create(super::keySet());
01459                     }
01460 
01461                 /**
01462                 * {@inheritDoc}
01463                 */
01464                 virtual Set::View keySet() const
01465                     {
01466                     return keySetTyped();
01467                     }
01468 
01469                 /**
01470                 * {@inheritDoc}
01471                 */
01472                 virtual Set::Handle keySet()
01473                     {
01474                     return keySetTyped();
01475                     }
01476 
01477                 /**
01478                 * The typed version of the method Map::values.
01479                 *
01480                 * Return a typed collection view of the values contained in
01481                 * this map.
01482                 *
01483                 * @return a typed collection view of the values contained in
01484                 *         this map.
01485                 */
01486                 virtual typename ValueCollection::View valuesTyped() const
01487                     {
01488                     return ValueCollection::create(super::values());
01489                     }
01490 
01491                 /**
01492                 * The typed version of the method Map::values.
01493                 *
01494                 * Return a typed collection view of the values contained in
01495                 * this map.
01496                 *
01497                 * @return a typed collection view of the values contained in
01498                 *         this map.
01499                 */
01500                 virtual typename ValueCollection::Handle valuesTyped()
01501                     {
01502                     return ValueCollection::create(super::values());
01503                     }
01504 
01505                 /**
01506                 * {@inheritDoc}
01507                 */
01508                 virtual Collection::View values() const
01509                     {
01510                     return valuesTyped();
01511                     }
01512 
01513                 /**
01514                 * {@inheritDoc}
01515                 */
01516                 virtual Collection::Handle values()
01517                     {
01518                     return valuesTyped();
01519                     }
01520 
01521                 /**
01522                 * The typed version of the method Map::entrySet.
01523                 *
01524                 * Return a typed set view of the mappings contained in
01525                 * this map.
01526                 *
01527                 * @return a typed set view of the mappings contained in
01528                 *         this map.
01529                 */
01530                 virtual typename EntrySet::View entrySetTyped() const
01531                     {
01532                     return EntrySet::create(cast<Set::View>(
01533                         ConverterCollections::ConverterSet::create(
01534                             super::entrySet(), f_vConverter,
01535                             (Converter::View) NULL)));
01536                     }
01537 
01538                 /**
01539                 * The typed version of the method Map::entrySet.
01540                 *
01541                 * Return a typed set view of the mappings contained in
01542                 * this map.
01543                 *
01544                 * @return a typed set view of the mappings contained in
01545                 *         this map.
01546                 */
01547                 virtual typename EntrySet::Handle entrySetTyped()
01548                     {
01549                     return EntrySet::create(cast<Set::Handle>(
01550                         ConverterCollections::ConverterSet::create(
01551                             super::entrySet(), f_vConverter,
01552                             (Converter::View) NULL)));
01553                     }
01554 
01555                 /**
01556                 * {@inheritDoc}
01557                 */
01558                 virtual Set::View entrySet() const
01559                     {
01560                     return entrySetTyped();
01561                     }
01562 
01563                 /**
01564                 * {@inheritDoc}
01565                 */
01566                 virtual Set::Handle entrySet()
01567                     {
01568                     return entrySetTyped();
01569                     }
01570 
01571 
01572             // ----- data members ---------------------------------------
01573 
01574             protected:
01575                 /**
01576                 * The converter used to convert untyped entries to typed ones
01577                 */
01578                 FinalView<EntryConverter> f_vConverter;
01579             };
01580 
01581 
01582         // ----- inner class: TypedList -------------------------------------
01583 
01584         /**
01585         * Typed wrapper over List interface.
01586         */
01587         template<class T>
01588         class TypedList
01589             : public cloneable_spec<TypedList<T>,
01590                 extends<WrapperCollections::AbstractWrapperList> >
01591             {
01592             friend class factory<TypedList<T> >;
01593             typedef typename TypedList::super super;
01594 
01595             // ----- typedefs -------------------------------------------
01596 
01597             public:
01598                 /**
01599                 * The type of the objects stored in this list,
01600                 * e.g. String::View.
01601                 */
01602                 typedef T ValueType;
01603 
01604                 /**
01605                 * The type of the iterator over this list.
01606                 */
01607                 typedef TypedIterator<ValueType> Iterator;
01608 
01609                 /**
01610                 * The type of the list iterator over this list.
01611                 */
01612                 typedef TypedListIterator<ValueType> ListIterator;
01613 
01614 
01615             // ----- constructors ---------------------------------------
01616 
01617             protected:
01618                 /**
01619                 * Create a new TypedList over the given List.
01620                 *
01621                 * @param ohListDelegate  the list to delegate to
01622                 */
01623                 TypedList(List::Holder ohListDelegate)
01624                     : super(ohListDelegate)
01625                     {
01626                     }
01627 
01628                 /**
01629                 * Copy constructor.
01630                 */
01631                 TypedList(const TypedList& that)
01632                     : super(that)
01633                     {
01634                     }
01635 
01636 
01637             // ----- TypedList interface --------------------------------
01638 
01639             public:
01640                 /**
01641                 * The typed version of the method List::get.
01642                 * <p>
01643                 * Return the element from the specified position in the list.
01644                 *
01645                 * @param i  the position of the item to return
01646                 *
01647                 * @return the element from the specified position in the list
01648                 *
01649                 * @throws coherence::lang::IndexOutOfBoundsException if the
01650                 *         index is out of range
01651                 *
01652                 * @throws ClassCastException
01653                 *         if the typed map is broken by external usage
01654                 */
01655                 virtual ValueType getTyped(size32_t i) const
01656                     {
01657                     return cast<ValueType>(super::get(i));
01658                     }
01659 
01660                 /**
01661                 * {@inheritDoc}
01662                 */
01663                 using super::contains;
01664 
01665                 /**
01666                 * The typed version of the method Collection::contains.
01667                 * Return true if this list contains the specified element.
01668                 *
01669                 * @param v element whose presence in this list is to be
01670                 *          tested
01671                 *
01672                 * @return true if this collection contains the specified
01673                 *         element
01674                 */
01675                 virtual bool contains(ValueType v) const
01676                     {
01677                     return super::contains(v);
01678                     }
01679 
01680                 /**
01681                 * The typed version of the method Collection::iterator.
01682                 * Return a handle to an TypedIterator over the elements in
01683                 * this list.
01684                 *
01685                 * @return a TypedIterator over the elements in this list
01686                 */
01687                 virtual typename TypedList::Iterator::Handle
01688                         iteratorTyped() const
01689                     {
01690                     return TypedList::Iterator::create(
01691                             Iterator::create(super::iterator()));
01692                     }
01693 
01694                 /**
01695                 * {@inheritDoc}
01696                 */
01697                 virtual coherence::util::Iterator::Handle iterator() const
01698                     {
01699                     return iteratorTyped();
01700                     }
01701 
01702                 /**
01703                 * {@inheritDoc}
01704                 */
01705                 virtual coherence::util::Muterator::Handle iterator()
01706                     {
01707                     return iteratorTyped();
01708                     }
01709 
01710                 /**
01711                 * The typed version of the method List::listIterator.
01712                 * <p>
01713                 * Return a handle to an TypedListIterator over the elements
01714                 * in this list.
01715                 *
01716                 * @return a TypedListIterator over the elements in this list
01717                 */
01718                 virtual typename TypedList::ListIterator::Handle
01719                         listIteratorTyped() const
01720                     {
01721                     return TypedList::ListIterator::create(
01722                             super::listIterator());
01723                     }
01724 
01725                 /**
01726                 * The typed version of the method List::listIterator.
01727                 * <p>
01728                 * Return a handle to an TypedListIterator over the elements
01729                 * in this list.
01730                 *
01731                 * @return a TypedListIterator over the elements in this list
01732                 */
01733                 virtual typename TypedList::ListIterator::Handle
01734                         listIteratorTyped()
01735                     {
01736                     return TypedList::ListIterator::create(
01737                         super::listIterator());
01738                     }
01739 
01740                 /**
01741                 * {@inheritDoc}
01742                 */
01743                 virtual coherence::util::ListIterator::Handle listIterator() const
01744                     {
01745                     return listIteratorTyped();
01746                     }
01747 
01748                 /**
01749                 * {@inheritDoc}
01750                 */
01751                 virtual coherence::util::ListMuterator::Handle listIterator()
01752                     {
01753                     return listIteratorTyped();
01754                     }
01755 
01756                 /**
01757                 * The typed version of the method Collection::iterator.
01758                 * <p> Return a handle to an TypedList Iterator over the
01759                 * elements in this list starting at the position specified.
01760                 *
01761                 * @param i  the position in the list that the iterator will
01762                 *           start at
01763                 *
01764                 * @return a TypedListIterator over the elements in this list
01765                 *         starting at the specified position in the list
01766                 */
01767                 virtual typename TypedList::ListIterator::Handle
01768                         listIteratorTyped(size32_t i) const
01769                     {
01770                     return TypedList::ListIterator::create(
01771                         super::listIterator(i));
01772                     }
01773 
01774                 /**
01775                 * The typed version of the method Collection::iterator.
01776                 * <p> Return a handle to an TypedList Iterator over the
01777                 * elements in this list starting at the position specified.
01778                 *
01779                 * @param i  the position in the list that the iterator will
01780                 *           start at
01781                 *
01782                 * @return a TypedListIterator over the elements in this list
01783                 *         starting at the specified position in the list
01784                 */
01785                 virtual typename TypedList::ListIterator::Handle
01786                         listIteratorTyped(size32_t i)
01787                     {
01788                     return TypedList::ListIterator::create(
01789                         super::listIterator(i));
01790                     }
01791 
01792                 /**
01793                 * {@inheritDoc}
01794                 */
01795                 virtual coherence::util::ListIterator::Handle
01796                         listIterator(size32_t i) const
01797                     {
01798                     return listIteratorTyped(i);
01799                     }
01800 
01801                 /**
01802                 * {@inheritDoc}
01803                 */
01804                 virtual coherence::util::ListMuterator::Handle
01805                         listIterator(size32_t i)
01806                     {
01807                     return listIteratorTyped(i);
01808                     }
01809 
01810                 /**
01811                 * {@inheritDoc}
01812                 */
01813                 using super::add;
01814 
01815                 /**
01816                 * The typed version of the method List::add. Add the
01817                 * specified element to this list if it is not already
01818                 * present.
01819                 *
01820                 * @param v element to be added to this list.
01821                 *
01822                 * @return true if this list changed as a result of the
01823                 *         call
01824                 *
01825                 * @throws coherence::lang::UnsupportedOperationException
01826                 *         if the #add() operation is not supported by this
01827                 *         list
01828                 */
01829                 virtual bool add(ValueType v)
01830                     {
01831                     return super::add(v);
01832                     }
01833 
01834                 /**
01835                 * {@inheritDoc}
01836                 */
01837                 using super::set;
01838 
01839                 /**
01840                 * The typed version of the method List::set.
01841                 * <p>
01842                 * Replace the element at the specified position in this list
01843                 * with the specified element.
01844                 *
01845                 * @param idx  the position in the list to replace
01846                 * @param v    the object to replace at the specified position
01847                 *
01848                 * @return the element at the specified position prior to this
01849                 *         operation
01850                 *
01851                 * @throw coherence::lang::IndexOutOfBoundsException if the
01852                 *        index is out of range
01853                 */
01854                 virtual ValueType set(size32_t idx, ValueType v)
01855                     {
01856                     return cast<ValueType>(super::set(idx, v));
01857                     }
01858 
01859                 /**
01860                 * {@inheritDoc}
01861                 */
01862                 using super::remove;
01863 
01864                 /**
01865                 * The typed version of the method Collection::remove. Remove
01866                 * the specified element from this list, if it is present.
01867                 *
01868                 * @param v element to be removed from this list, if present
01869                 *
01870                 * @return true if this list changed as a result of
01871                 *         the call
01872                 *
01873                 * @throws coherence::lang::UnsupportedOperationException
01874                 *         if the #remove() operation is not supported by this
01875                 *         list
01876                 */
01877                 virtual bool remove(ValueType v)
01878                     {
01879                     return super::remove(v);
01880                     }
01881 
01882                 /**
01883                 * The typed version of the method Collection::remove.
01884                 * <p> Remove the element at the specified position in the
01885                 * list.
01886                 *
01887                 * @param idx  the index from which to remove an element
01888                 *
01889                 * @return the element at the specified position prior to this
01890                 *         operation
01891                 *
01892                 * @throw coherence::lang::IndexOutOfBoundsException if the
01893                 *        index is out of range
01894                 */
01895                 virtual ValueType removeTyped(size32_t idx)
01896                     {
01897                     return cast<ValueType>(super::remove(idx));
01898                     }
01899 
01900                 /**
01901                 * {@inheritDoc}
01902                 */
01903                 using super::addAll;
01904 
01905 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
01906                 /**
01907                 * The typed version of the method Collection::addAll.
01908                 *
01909                 * Add all of the elements in the specified TypedCollection to
01910                 * this list.
01911                 *
01912                 * @param vtc TypedCollection of elements to be inserted into
01913                 *            this list
01914                 *
01915                 * @return true if this list changed as a result of the call
01916                 *
01917                 * @throws coherence::lang::NullPointerException
01918                 *         if the specified collection is NULL
01919                 * @throws coherence::lang::UnsupportedOperationException
01920                 *         if the #add() operation is not supported by this
01921                 *         list
01922                 */
01923                 virtual bool addAll(typename
01924                                 TypedCollection<ValueType>::View vtc)
01925                     {
01926                     return super::addAll(vtc);
01927                     }
01928 
01929                 /**
01930                 * The typed version of the method Collection::addAll.
01931                 *
01932                 * Add all of the elements in the specified TypedCollection to
01933                 * this list.
01934                 *
01935                 * @param htc TypedCollection of elements to be inserted into
01936                 *            this list
01937                 *
01938                 * @return true if this list changed as a result of the call
01939                 *
01940                 * @throws coherence::lang::NullPointerException
01941                 *         if the specified collection is NULL
01942                 * @throws coherence::lang::UnsupportedOperationException
01943                 *         if the #add() operation is not supported by this
01944                 *         list
01945                 */
01946                 virtual bool addAll(typename
01947                                 TypedCollection<ValueType>::Handle htc)
01948                     {
01949                     return super::addAll(htc);
01950                     }
01951 #endif
01952 
01953                 /**
01954                 * The typed version of the method Collection::addAll.
01955                 *
01956                 * Add all of the elements in the specified TypedList to this
01957                 * list.
01958                 *
01959                 * @param vtl TypedList of elements to be inserted into
01960                 *            this list
01961                 *
01962                 * @return true if this list changed as a result of the call
01963                 *
01964                 * @throws coherence::lang::NullPointerException
01965                 *         if the specified collection is NULL
01966                 * @throws coherence::lang::UnsupportedOperationException
01967                 *         if the #add() operation is not supported by this
01968                 *         list
01969                 */
01970                 virtual bool addAll(
01971                         typename TypedList<ValueType>::View vtl)
01972                     {
01973                     return super::addAll(vtl);
01974                     }
01975 
01976                 /**
01977                 * The typed version of the method Collection::addAll.
01978                 *
01979                 * Add all of the elements in the specified TypedList to this
01980                 * list.
01981                 *
01982                 * @param htl TypedList of elements to be inserted into
01983                 *            this list
01984                 *
01985                 * @return true if this list changed as a result of the call
01986                 *
01987                 * @throws coherence::lang::NullPointerException
01988                 *         if the specified collection is NULL
01989                 * @throws coherence::lang::UnsupportedOperationException
01990                 *         if the #add() operation is not supported by this
01991                 *         list
01992                 */
01993                 virtual bool addAll(
01994                         typename TypedList<ValueType>::Handle htl)
01995                     {
01996                     return super::addAll(htl);
01997                     }
01998 
01999                 /**
02000                 * {@inheritDoc}
02001                 */
02002                 using super::removeAll;
02003 
02004 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
02005                 /**
02006                 * The typed version of the method Collection::removeAll.
02007                 *
02008                 * Remove all this list's elements that are also contained in
02009                 * the specified typed collection.
02010                 *
02011                 * @param vtc elements to be removed from this list
02012                 *
02013                 * @return true if this list changed as a result of
02014                 *         the call
02015                 *
02016                 * @throws coherence::lang::NullPointerException
02017                 *         if the specified collection is NULL
02018                 * @throws coherence::lang::UnsupportedOperationException
02019                 *         if the #remove() operation is not supported by this
02020                 *         list
02021                 */
02022                 virtual bool removeAll(typename
02023                                 TypedCollection<ValueType>::View vtc)
02024                     {
02025                     return super::removeAll(vtc);
02026                     }
02027 
02028                 /**
02029                 * The typed version of the method Collection::removeAll.
02030                 *
02031                 * Remove all this list's elements that are also contained in
02032                 * the specified typed collection.
02033                 *
02034                 * @param htc elements to be removed from this list
02035                 *
02036                 * @return true if this list changed as a result of
02037                 *         the call
02038                 *
02039                 * @throws coherence::lang::NullPointerException
02040                 *         if the specified collection is NULL
02041                 * @throws coherence::lang::UnsupportedOperationException
02042                 *         if the #remove() operation is not supported by this
02043                 *         list
02044                 */
02045                 virtual bool removeAll(typename
02046                                 TypedCollection<ValueType>::Handle htc)
02047                     {
02048                     return super::removeAll(htc);
02049                     }
02050 #endif
02051 
02052                 /**
02053                 * The typed version of the method Collection::removeAll.
02054                 *
02055                 * Remove all this list's elements that are also contained in
02056                 * the specified typed list.
02057                 *
02058                 * @param vtl elements to be removed from this list
02059                 *
02060                 * @return true if this list changed as a result of
02061                 *         the call
02062                 *
02063                 * @throws coherence::lang::NullPointerException
02064                 *         if the specified collection is NULL
02065                 * @throws coherence::lang::UnsupportedOperationException
02066                 *         if the #remove() operation is not supported by this
02067                 *         list
02068                 */
02069                 virtual bool removeAll(typename
02070                                 TypedList<ValueType>::View vtl)
02071                     {
02072                     return super::removeAll(vtl);
02073                     }
02074 
02075                 /**
02076                 * The typed version of the method Collection::removeAll.
02077                 *
02078                 * Remove all this list's elements that are also contained in
02079                 * the specified typed list.
02080                 *
02081                 * @param htl elements to be removed from this list
02082                 *
02083                 * @return true if this list changed as a result of
02084                 *         the call
02085                 *
02086                 * @throws coherence::lang::NullPointerException
02087                 *         if the specified collection is NULL
02088                 * @throws coherence::lang::UnsupportedOperationException
02089                 *         if the #remove() operation is not supported by this
02090                 *         list
02091                 */
02092                 virtual bool removeAll(typename
02093                                 TypedList<ValueType>::Handle htl)
02094                     {
02095                     return super::removeAll(htl);
02096                     }
02097 
02098                 /**
02099                 * {@inheritDoc}
02100                 */
02101                 using super::retainAll;
02102 
02103 #if (!defined(_MSC_VER) || _MSC_VER==1400) // COH-3357 - works on all compilers but VS2008+
02104                 /**
02105                 * The typed version of the method Collection::retainAll.
02106                 *
02107                 * Retain only the elements in this list that are
02108                 * contained in the specified typed collection.
02109                 *
02110                 * @param vtc elements to be retained in this list
02111                 *
02112                 * @return true if this list changed as a result of
02113                 *         the call
02114                 *
02115                 * @throws coherence::lang::NullPointerException
02116                 *         if the specified collection is NULL
02117                 * @throws coherence::lang::UnsupportedOperationException
02118                 *         if the #remove() operation is not supported by this
02119                 *         list
02120                 */
02121                 virtual bool retainAll(typename
02122                                 TypedCollection<ValueType>::View vtc)
02123                     {
02124                     return super::retainAll(vtc);
02125                     }
02126 
02127                 /**
02128                 * The typed version of the method Collection::retainAll.
02129                 *
02130                 * Retain only the elements in this list that are
02131                 * contained in the specified typed collection.
02132                 *
02133                 * @param htc elements to be retained in this list
02134                 *
02135                 * @return true if this list changed as a result of
02136                 *         the call
02137                 *
02138                 * @throws coherence::lang::NullPointerException
02139                 *         if the specified collection is NULL
02140                 * @throws coherence::lang::UnsupportedOperationException
02141                 *         if the #remove() operation is not supported by this
02142                 *         list
02143                 */
02144                 virtual bool retainAll(typename
02145                                 TypedCollection<ValueType>::Handle htc)
02146                     {
02147                     return super::retainAll(htc);
02148                     }
02149 #endif
02150 
02151                 /**
02152                 * The typed version of the method Collection::retainAll.
02153                 *
02154                 * Retain only the elements in this list that are
02155                 * contained in the specified typed list.
02156                 *
02157                 * @param vtl elements to be retained in this list
02158                 *
02159                 * @return true if this list changed as a result of
02160                 *         the call
02161                 *
02162                 * @throws coherence::lang::NullPointerException
02163                 *         if the specified collection is NULL
02164                 * @throws coherence::lang::UnsupportedOperationException
02165                 *         if the #remove() operation is not supported by this
02166                 *         list
02167                 */
02168                 virtual bool retainAll(typename
02169                                 TypedList<ValueType>::View vtl)
02170                     {
02171                     return super::retainAll(vtl);
02172                     }
02173 
02174                 /**
02175                 * The typed version of the method Collection::retainAll.
02176                 *
02177                 * Retain only the elements in this list that are
02178                 * contained in the specified typed list.
02179                 *
02180                 * @param htl elements to be retained in this list
02181                 *
02182                 * @return true if this list changed as a result of
02183                 *         the call
02184                 *
02185                 * @throws coherence::lang::NullPointerException
02186                 *         if the specified collection is NULL
02187                 * @throws coherence::lang::UnsupportedOperationException
02188                 *         if the #remove() operation is not supported by this
02189                 *         list
02190                 */
02191                 virtual bool retainAll(typename
02192                                 TypedList<ValueType>::Handle htl)
02193                     {
02194                     return super::retainAll(htl);
02195                     }
02196 
02197                 /**
02198                 * Convert a TypedList to a TypedCollection, wrapping the same
02199                 * underlying Collection::Handle.
02200                 *
02201                 * @return a handle to the new TypedCollection
02202                 */
02203                 virtual typename TypedCollection<ValueType>::Handle
02204                         asTypedCollection()
02205                     {
02206                     return TypedCollection<ValueType>::create(
02207                         cast<Collection::Handle>(super::getDelegate()));
02208                     }
02209 
02210                 /**
02211                 * Convert a TypedList to a TypedCollection, wrapping the same
02212                 * underlying Collection::View.
02213                 *
02214                 * @return a view to the new TypedCollection
02215                 */
02216                 virtual typename TypedCollection<ValueType>::View
02217                         asTypedCollection() const
02218                     {
02219                     return TypedCollection<ValueType>::create(
02220                         cast<Collection::View>(super::getDelegate()));
02221                     }
02222 
02223                 /**
02224                 * The typed version of the method Collection::subList.
02225                 * <p> Return a new typed list containing the contents of the
02226                 * list between the specified fromIndex (inclusive) and
02227                 * toIndex (exclusive).
02228                 *
02229                 * @param fromIndex  the start position in this list to create
02230                 *                   the sublist from (inclusive).
02231                 * @param toIndex    the end position in this list to end the
02232                 *                   sublist at (exclusive).
02233                 *
02234                 * @return the new typed sublist of this typed list
02235                 */
02236                 virtual typename TypedList::Handle subListTyped(
02237                         size32_t fromIndex, size32_t toIndex)
02238                     {
02239                     return TypedList::create(super::subList(fromIndex, toIndex));
02240                     }
02241 
02242                 /**
02243                 * The typed version of the method Collection::subList.
02244                 * <p> Return a new typed list containing the contents of the
02245                 * list between the specified fromIndex (inclusive) and
02246                 * toIndex (exclusive).
02247                 *
02248                 * @param fromIndex  the start position in this list to create
02249                 *                   the sublist from (inclusive).
02250                 * @param toIndex    the end position in this list to end the
02251                 *                   sublist at (exclusive).
02252                 *
02253                 * @return the new typed sublist of this typed list
02254                 */
02255                 virtual typename TypedList::Handle subListTyped(
02256                         size32_t fromIndex, size32_t toIndex) const
02257                     {
02258                     return TypedList::create(super::subList(fromIndex, toIndex));
02259                     }
02260             };
02261     };
02262 
02263 COH_CLOSE_NAMESPACE2
02264 
02265 #endif // COH_TYPED_COLLECTIONS_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.