activemq-cpp-3.8.2
LinkedHashSet.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_UTIL_LINKEDHASHSET_H_
19 #define _DECAF_UTIL_LINKEDHASHSET_H_
20 
21 #include <decaf/util/Config.h>
22 
24 #include <decaf/util/HashSet.h>
27 
28 namespace decaf {
29 namespace util {
30 
90  template<typename E, typename HASHCODE = HashCode<E> >
91  class LinkedHashSet : public HashSet<E, HASHCODE> {
92  public:
93 
98  LinkedHashSet() : HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>()) {
99  }
100 
108  LinkedHashSet(int capacity) : HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(capacity)) {
109  }
110 
120  LinkedHashSet(int capacity, float loadFactor) :
121  HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(capacity, loadFactor)) {
122  }
123 
133  LinkedHashSet(const Collection<E>& collection) :
134  HashSet<E, HASHCODE>(new LinkedHashMap<E, Set<E>*, HASHCODE>(
135  (collection.size() < 6 ? 11 : collection.size() * 2))) {
136 
137  decaf::lang::Pointer<Iterator<E> > iter(collection.iterator());
138  while (iter->hasNext()) {
139  this->add(iter->next());
140  }
141  }
142 
143  virtual ~LinkedHashSet() {
144  }
145 
146  virtual std::string toString() const {
147  return "LinkedHashSet";
148  }
149  };
150 
151 }}
152 
153 #endif /* _DECAF_UTIL_LINKEDHASHSET_H_ */
virtual std::string toString() const
Definition: LinkedHashSet.h:146
The root interface in the collection hierarchy.
Definition: Collection.h:68
A collection that contains no duplicate elements.
Definition: Set.h:45
LinkedHashSet(int capacity, float loadFactor)
Constructs a new instance of.
Definition: LinkedHashSet.h:120
This class implements the Set interface, backed by a hash table (actually a HashMap instance)...
Definition: HashSet.h:70
Hash table and linked list implementation of the Set interface, with predictable iteration order...
Definition: LinkedHashSet.h:91
LinkedHashSet(const Collection< E > &collection)
Constructs a new set containing the elements in the specified collection.
Definition: LinkedHashSet.h:133
virtual ~LinkedHashSet()
Definition: LinkedHashSet.h:143
virtual bool add(const E &value)
Adds the specified element to this set if it is not already present.
Definition: HashSet.h:168
Hashed and linked list implementation of the Map interface, with predictable iteration order...
Definition: LinkedHashMap.h:111
virtual decaf::util::Iterator< E > * iterator()=0
LinkedHashSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load ...
Definition: LinkedHashSet.h:98
virtual int size() const
Returns the number of elements in this.
Definition: HashSet.h:263
LinkedHashSet(int capacity)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and defa...
Definition: LinkedHashSet.h:108
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25