Permalink
Browse files

Add some missing methods.

  • Loading branch information...
1 parent 9c8ab03 commit e32e2efb9f385930b604709e4bc698839a00232d @tabish121 tabish121 committed Oct 18, 2013
Showing with 36 additions and 0 deletions.
  1. +16 −0 activemq-cpp/src/main/decaf/util/AbstractCollection.h
  2. +20 −0 activemq-cpp/src/main/decaf/util/HashSet.h
View
16 activemq-cpp/src/main/decaf/util/AbstractCollection.h
@@ -64,6 +64,22 @@ namespace util {
AbstractCollection() : Collection<E>(), mutex() {}
+ /**
+ * Copy Constructor, copy element from the source collection to this
+ * collection after clearing any element stored in this collection.
+ *
+ * @param collection - the collection to copy
+ */
+ AbstractCollection(const AbstractCollection& other) : Collection<E>(), mutex() {
+ if (other.isEmpty()) {
+ return;
+ }
+ std::auto_ptr<Iterator<E> > iter(other.iterator());
+ while (iter->hasNext()) {
+ this->add(iter->next());
+ }
+ }
+
virtual ~AbstractCollection() {}
/**
View
20 activemq-cpp/src/main/decaf/util/HashSet.h
@@ -122,6 +122,26 @@ namespace util {
}
}
+ /**
+ * Constructs a new set containing the elements in the specified HashSet.
+ *
+ * The HashMap is created with default load factor (0.75) and an initial capacity
+ * sufficient to contain the elements in the specified collection.
+ *
+ * @param collection
+ * The collection of elements to add to this HashSet.
+ */
+ HashSet(const HashSet<E>& collection) : AbstractSet<E>(), backingMap() {
+
+ this->backingMap = new HashMap<E, Set<E>*, HASHCODE>(
+ (collection.size() < 6 ? 11 : collection.size() * 2));
+
+ decaf::lang::Pointer<Iterator<E> > iter(collection.iterator());
+ while (iter->hasNext()) {
+ this->add(iter->next());
+ }
+ }
+
virtual ~HashSet() {
try {
delete this->backingMap;

0 comments on commit e32e2ef

Please sign in to comment.