コード例 #1
0
ファイル: list.cpp プロジェクト: rosario-raulin/cpp-course
 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();
     }
 }
コード例 #2
0
		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;
			}
		}