00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_UTIL_LINKEDHASHSET_H_
00019 #define _DECAF_UTIL_LINKEDHASHSET_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 #include <decaf/util/LinkedHashMap.h>
00024 #include <decaf/util/HashSet.h>
00025 #include <decaf/util/ConcurrentModificationException.h>
00026 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
00027
00028 namespace decaf {
00029 namespace util {
00030
00090 template<typename E, typename HASHCODE = HashCode<E> >
00091 class LinkedHashSet : public HashSet<E, HASHCODE> {
00092 public:
00093
00098 LinkedHashSet() : HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>()) {
00099 }
00100
00108 LinkedHashSet(int capacity) : HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(capacity)) {
00109 }
00110
00120 LinkedHashSet(int capacity, float loadFactor) :
00121 HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(capacity, loadFactor)) {
00122 }
00123
00133 LinkedHashSet(const Collection<E>& collection) :
00134 HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(
00135 (collection.size() < 6 ? 11 : collection.size() * 2))) {
00136
00137 decaf::lang::Pointer<Iterator<E> > iter(collection.iterator());
00138 while (iter->hasNext()) {
00139 this->add(iter->next());
00140 }
00141 }
00142
00143 virtual ~LinkedHashSet() {
00144 }
00145
00146 virtual std::string toString() const {
00147 return "LinkedHashSet";
00148 }
00149 };
00150
00151 }}
00152
00153 #endif