C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/util/MapKeySet.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_MAP_KEYSET_HPP
00008 #define COH_MAP_KEYSET_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/util/ConverterCollections.hpp"
00013 
00014 COH_OPEN_NAMESPACE2(coherence,util)
00015 
00016 
00017 /**
00018 * A wrapper class that provides the Set interface for the key set of a map.
00019 * It's returned by the default implementation of the AbstractMap::keySet()
00020 * method. MapKeySet is based on the ConverterCollections functionality which
00021 * will convert a map's entrySet into a KeySet
00022 *
00023 * Note that because this ConverterSet is based on the Map's entrySet, all
00024 * write operations on the set must be converted out to a method on the Map,
00025 * not the keyset.
00026 *
00027 * @author nsa 2008.01.31
00028 */
00029 class COH_EXPORT MapKeySet
00030     : public class_spec<MapKeySet,
00031         extends<ConverterCollections::ConverterSet> >
00032     {
00033     friend class factory<MapKeySet>;
00034 
00035     // ----- constructors ---------------------------------------------------
00036 
00037     protected:
00038         /**
00039         * Create a KeySet which delegates to the specified Set or Map
00040         * depending on the operation.
00041         *
00042         * @param hMap  the specfied Map.
00043         */
00044         MapKeySet(Map::Handle hMapDelegate);
00045 
00046         /**
00047         * Create a WrapperCollections#AbstractWrapperSet which
00048         * delegates to the specified Set.
00049         *
00050         * @param vMap  the specified Map.
00051         */
00052         MapKeySet(Map::View vMapDelegate);
00053 
00054 
00055     // ----- Set interface --------------------------------------------------
00056 
00057     public:
00058         /**
00059         * {@inheritDoc}
00060         */
00061         virtual bool remove(Object::View v);
00062 
00063           /**
00064         * @{inheritDoc}
00065         */
00066         virtual bool removeAll(Collection::View vc);
00067 
00068         /**
00069         * @{inheritDoc}
00070         */
00071         virtual bool retainAll(Collection::View vc);
00072 
00073         /**
00074         * @{inheritDoc}
00075         */
00076         virtual bool contains(Object::View v) const;
00077 
00078         /**
00079         * @{inheritDoc}
00080         */
00081         virtual bool containsAll(Collection::View vc) const;
00082 
00083 
00084     // ----- accessors methods ----------------------------------------------
00085 
00086     protected:
00087         /**
00088         * Return the delegate Map instance.
00089         *
00090         * @return the delegate Map instance
00091         */
00092         virtual Map::Handle getMapDelegate();
00093 
00094         /**
00095         * Return the delegate Map instance.
00096         *
00097         * @return the delegate Map instance
00098         */
00099         virtual Map::View getMapDelegate() const;
00100 
00101 
00102     // ----- inner class: KeyConverter ------------------------------------
00103 
00104     public:
00105         /**
00106         * Convert a Map::Entry into a Map::Entry::Key
00107         */
00108         class KeyConverter
00109             : public class_spec<KeyConverter,
00110                 extends<Object>,
00111                 implements<Converter> >
00112             {
00113             friend class factory<KeyConverter>;
00114 
00115             // ----- constructor ----------------------------------------
00116 
00117             protected:
00118                 /**
00119                 * Create a new KeyConverter
00120                 */
00121                 KeyConverter();
00122 
00123             // ----- Converter interface --------------------------------
00124 
00125             public:
00126                 /**
00127                 * Convert an {@link coherence::lang::Object Object} referenced
00128                 * by the supplied holder.
00129                 *
00130                 * @param oh the holder to the Object to convert
00131                 *
00132                 * @return the holder to the converted Object
00133                 */
00134                 virtual Object::Holder convert(Object::Holder oh) const;
00135 
00136                 /**
00137                 * Return a singleton instance of the ValueConverter.
00138                 */
00139                 static KeyConverter::View getInstance();
00140             };
00141 
00142 
00143     // ----- data members ---------------------------------------------------
00144 
00145     protected:
00146         /**
00147         * The underlying map
00148         */
00149         FinalHolder<Map> f_thMapDelegate;
00150     };
00151 
00152 COH_CLOSE_NAMESPACE2
00153 
00154 #endif // COH_MAP_KEYSET_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.