18 #ifndef _DECAF_UTIL_HASHSET_H_ 19 #define _DECAF_UTIL_HASHSET_H_ 69 template<
typename E,
typename HASHCODE = HashCode<E> >
119 (collection.
size() < 6 ? 11 : collection.
size() * 2));
122 while (iter->hasNext()) {
123 this->
add(iter->next());
168 virtual bool add(
const E& value) {
169 return this->backingMap->
put(value,
this);
179 this->backingMap->
clear();
219 return this->backingMap->
isEmpty();
229 return this->backingMap->
keySet().iterator();
233 return this->backingMap->
keySet().iterator();
248 virtual bool remove(
const E& value) {
250 this->backingMap->
remove(value);
264 return this->backingMap->
size();
271 result.append(
"decaf::util::HashSet [ size = ");
HashSet< E > & operator=(const Collection< E > &collection)
Definition: HashSet.h:149
The root interface in the collection hierarchy.
Definition: Collection.h:68
A collection that contains no duplicate elements.
Definition: Set.h:45
This class implements the Set interface, backed by a hash table (actually a HashMap instance)...
Definition: HashSet.h:70
virtual void clear()
Removes all elements from this.
Definition: HashSet.h:178
virtual bool put(const K &key, const V &value)
Associates the specified value with the specified key in this map (optional operation).
Definition: HashMap.h:985
HashSet(const Collection< E > &collection)
Constructs a new set containing the elements in the specified collection.
Definition: HashSet.h:116
#define DECAF_CATCHALL_NOTHROW()
A catch-all that does not throw an exception, one use would be to catch any exception in a destructor...
Definition: ExceptionDefines.h:62
virtual bool contains(const E &value) const
Returns a new.
Definition: HashSet.h:207
virtual V remove(const K &key)
Removes the value (key/value pair) for the specified key from the map, returns a copy of the value th...
Definition: HashMap.h:999
virtual ~HashSet()
Definition: HashSet.h:127
virtual Iterator< E > * iterator()
Returns an Iterator on the elements of this.
Definition: HashSet.h:228
virtual int size() const =0
Returns the number of elements in this collection.
virtual void clear()
Removes all of the mappings from this map (optional operation).
Definition: HashMap.h:923
virtual bool containsKey(const K &key) const
Returns true if this map contains a mapping for the specified key.
Definition: HashMap.h:947
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
virtual bool isEmpty() const
Returns true if this.
Definition: HashSet.h:218
HashMap< E, Set< E > *, HASHCODE > * backingMap
Definition: HashSet.h:73
virtual Iterator< E > * iterator() const
Definition: HashSet.h:232
virtual bool add(const E &value)
Adds the specified element to this set if it is not already present.
Definition: HashSet.h:168
virtual std::string toString() const
Definition: HashSet.h:267
virtual decaf::util::Iterator< E > * iterator()=0
virtual bool addAll(const Collection< E > &collection)
Adds all of the elements in the specified collection to this collection.The behavior of this operatio...
Definition: AbstractCollection.h:223
virtual int size() const
Definition: HashMap.h:943
HashSet(int capacity)
Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and defa...
Definition: HashSet.h:91
virtual int size() const
Returns the number of elements in this.
Definition: HashSet.h:263
HashSet(int capacity, float loadFactor)
Constructs a new instance of.
Definition: HashSet.h:103
virtual bool isEmpty() const
Definition: HashMap.h:939
HashSet(HashMap< E, Set< E > *, HASHCODE > *backingMap)
Protected constructor for use by subclasses that wish to use an alternate type of backing Map...
Definition: HashSet.h:143
Hash table based implementation of the Map interface.
Definition: HashMap.h:95
std::string toString() const
Definition: NoSuchElementException.h:31
This class provides a skeletal implementation of the Set interface to minimize the effort required to...
Definition: AbstractSet.h:46
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
virtual Set< K > & keySet()
Returns a Set view of the keys contained in this map.
Definition: HashMap.h:1025
HashSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load ...
Definition: HashSet.h:81
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25