SingleLinkedList::SingleLinkedList(const ICollection& other) { size = other.getNumElements(); auto it = other.getIterator(); while (it->current() != nullptr) { m_first = new ListEntry(m_first, it->current()); it->next(); } }
ArrayList(const ICollection<T>& other) { m_numElements = other.getNumElements(); capacity = 2*(m_numElements); data = new T[capacity]; int i = 0; auto it = other.getIterator(); while (it->current() != nullptr) { data[i] = *it->current(); it->next(); ++i; } }