00001 /* 00002 * HashSet.hpp 00003 * 00004 * Copyright (c) 2000, 2013, 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_HASH_SET_HPP 00017 #define COH_HASH_SET_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/MappedSet.hpp" 00022 00023 COH_OPEN_NAMESPACE2(coherence,util) 00024 00025 00026 /** 00027 * Set implementation which is backed by a HashMap. 00028 * 00029 * @author mf 2008.02.25 00030 */ 00031 class COH_EXPORT HashSet 00032 : public cloneable_spec<HashSet, 00033 extends<MappedSet> > 00034 { 00035 friend class factory<HashSet>; 00036 00037 // ----- constructors --------------------------------------------------- 00038 00039 protected: 00040 /** 00041 * Construct a hash set using the specified settings. 00042 * 00043 * @param cInitialBuckets the initial number of hash buckets, 00044 * 0 < n 00045 * @param flLoadFactor the acceptable load factor before resizing 00046 * occurs, 0 < n, such that a load factor 00047 * of 1.0 causes resizing when the number of 00048 * entries exceeds the number of buckets 00049 * @param flGrowthRate the rate of bucket growth when a resize 00050 * occurs, 0 < n, such that a growth rate 00051 * of 1.0 will double the number of buckets: 00052 * bucketcount = bucketcount * (1 + growthrate) 00053 */ 00054 HashSet(size32_t cInitialBuckets = default_initial_buckets, 00055 float32_t flLoadFactor = getDefaultLoadFactor(), 00056 float32_t flGrowthRate = getDefaultGrowthRate()); 00057 00058 /** 00059 * Constructs a new set containing the elements in the specified 00060 * Collection. The HashSet is created with default load factor (1.0) 00061 * and an initial capacity sufficient to contain the elements in the 00062 * specified collection. 00063 * 00064 * @param vCol the collection whose elements are to be placed into this set 00065 * 00066 * @since Coherence 12.1.2 00067 */ 00068 HashSet(Collection::View vCol); 00069 00070 /** 00071 * Copy constructor. 00072 */ 00073 HashSet(const HashSet& that); 00074 00075 00076 // ----- constants --------------------------------------------------- 00077 00078 public: 00079 /** 00080 * The default value for initial number of hash buckets. 00081 */ 00082 static const size32_t default_initial_buckets = 17; 00083 00084 /** 00085 * The default acceptable load factor before resizing occurs (1.0F). 00086 */ 00087 static float32_t getDefaultLoadFactor(); 00088 00089 /** 00090 * The default rate of bucket growth when a resize occurs (3.0F). 00091 */ 00092 static float32_t getDefaultGrowthRate(); 00093 }; 00094 00095 COH_CLOSE_NAMESPACE2 00096 00097 #endif // COH_HASH_SET