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

E90870-01

coherence/util/IdentityHashMap.hpp

00001 /*
00002 * IdentityHashMap.hpp
00003 *
00004 * Copyright (c) 2000, 2019, 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_IDENTITY_HASH_MAP_HPP
00017 #define COH_IDENTITY_HASH_MAP_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/SafeHashMap.hpp"
00022 
00023 COH_OPEN_NAMESPACE2(coherence,util)
00024 
00025 
00026 /**
00027 * IdentityHashMap is a HashMap implementation where key equality is based
00028 * on reference rather then value equality.
00029 *
00030 * @author mf  2008.05.27
00031 */
00032 class COH_EXPORT IdentityHashMap
00033     : public cloneable_spec<IdentityHashMap,
00034         extends<SafeHashMap> >
00035     {
00036     friend class factory<IdentityHashMap>;
00037 
00038     // ----- constructors ---------------------------------------------------
00039 
00040     protected:
00041         /**
00042         * Construct a thread-safe weak hash map using the specified settings.
00043         *
00044         * @param cInitialBuckets  the initial number of hash buckets,
00045         *                         0 &lt; n
00046         * @param flLoadFactor     the acceptable load factor before resizing
00047         *                         occurs, 0 &lt; n, such that a load factor
00048         *                         of 1.0 causes resizing when the number of
00049         *                         entries exceeds the number of buckets
00050         * @param flGrowthRate     the rate of bucket growth when a resize
00051         *                         occurs, 0 &lt; n, such that a growth rate
00052         *                         of 1.0 will double the number of buckets:
00053         *                         bucketcount = bucketcount * (1 + growthrate)
00054         */
00055         IdentityHashMap(size32_t cInitialBuckets = 17,
00056                 float32_t flLoadFactor = 1.0F,
00057                 float32_t flGrowthRate = 3.0F);
00058 
00059         /**
00060         * Copy Constructor.
00061         */
00062         IdentityHashMap(const IdentityHashMap& that);
00063 
00064 
00065     // ----- SafeHashMap interface ------------------------------------------
00066 
00067     protected:
00068         /**
00069         * {@inheritDoc}
00070         */
00071         virtual SafeHashMap::Entry::Handle instantiateEntry(Object::View vKey,
00072                 Object::Holder ohValue, size32_t nHash);
00073 
00074         /**
00075         * {@inheritDoc}
00076         */
00077         virtual SafeHashMap::Entry::Handle instantiateEntry(
00078                 SafeHashMap::Entry::View vEntry);
00079 
00080         /**
00081         * {@inheritDoc}
00082         */
00083         virtual size32_t getHashCode(Object::View vKey) const;
00084 
00085     // ----- inner class: Entry ---------------------------------------------
00086 
00087     protected:
00088         /**
00089         * A Map::Entry where key equality is based on reference equality.
00090         */
00091         class COH_EXPORT Entry
00092             : public cloneable_spec<Entry,
00093                 extends<SafeHashMap::Entry> >
00094             {
00095             friend class factory<Entry>;
00096 
00097             // ----- constructors -------------------------------------
00098 
00099             protected:
00100                 /**
00101                 * Create a new Map::Entry.
00102                 *
00103                 * @param vKey     the associated key
00104                 * @param ohValue  the associated value
00105                 * @param hHash    the associated hash code
00106                 *
00107                 * @return a new Map::Entry
00108                 */
00109                 Entry(Object::View vKey, Object::Holder ohValue,
00110                         size32_t nHash);
00111 
00112                 /**
00113                 * Copy constructor
00114                 */
00115                 Entry(const Entry& that);
00116 
00117                 /**
00118                 * Copy an Entry.
00119                 *
00120                 * @param vThat  the entry to copy
00121                 */
00122                 Entry(Entry::View vThat);
00123 
00124             // ----- SafeHashMap::Entry interface -----------------------
00125 
00126             protected:
00127                 /**
00128                 * {@inheritDoc}
00129                 */
00130                 virtual bool isKeyEqual(Object::View vKey) const;
00131             };
00132     };
00133 
00134 COH_CLOSE_NAMESPACE2
00135 
00136 #endif // COH_IDENTITY_HASH_MAP_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.