diff --git a/librerie/exercise3/binarytree/binarytree.cpp b/librerie/exercise3/binarytree/binarytree.cpp index 028f727..862cde2 100755 --- a/librerie/exercise3/binarytree/binarytree.cpp +++ b/librerie/exercise3/binarytree/binarytree.cpp @@ -465,8 +465,8 @@ BTInOrderIterator::BTInOrderIterator(const BTInOrderIterator& itr){ template BTInOrderIterator::BTInOrderIterator(BTInOrderIterator&& toMove) noexcept{ - std::move(curr, toMove.curr); - std::move(stack, toMove.stack); + std::swap(curr, toMove.curr); + std::swap(stack, toMove.stack); } template @@ -484,8 +484,8 @@ BTInOrderIterator& BTInOrderIterator::operator=(const BTInOrderItera template BTInOrderIterator& BTInOrderIterator::operator=(BTInOrderIterator&& toMove) noexcept{ - std::move(curr, toMove.curr); - std::move(stack, toMove.stack); + std::swap(curr, toMove.curr); + std::swap(stack, toMove.stack); return *this; } diff --git a/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp b/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp index eca6ed9..3167335 100755 --- a/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp +++ b/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp @@ -134,7 +134,6 @@ BinaryTreeLnk& BinaryTreeLnk::operator=(const BinaryTreeLnk& t template BinaryTreeLnk& BinaryTreeLnk::operator=(BinaryTreeLnk&& tree) noexcept{ - Clear(); std::swap(size, tree.size); std::swap(root, tree.root); return *this; diff --git a/librerie/exercise3/binarytree/vec/binarytreevec.cpp b/librerie/exercise3/binarytree/vec/binarytreevec.cpp index f954771..2bc3694 100755 --- a/librerie/exercise3/binarytree/vec/binarytreevec.cpp +++ b/librerie/exercise3/binarytree/vec/binarytreevec.cpp @@ -117,12 +117,14 @@ BinaryTreeVec& BinaryTreeVec::operator=(const BinaryTreeVec& b template BinaryTreeVec& BinaryTreeVec::operator=(BinaryTreeVec&& bt) noexcept{ - Clear(); std::swap(size, bt.size); std::swap(tree, bt.tree); for(ulong i=0 ; iReferenceToTree = this; } + for(ulong j=0 ; jReferenceToTree = &bt; + } return *this; } diff --git a/librerie/exercise3/list/list.cpp b/librerie/exercise3/list/list.cpp index 3396301..05c06d1 100644 --- a/librerie/exercise3/list/list.cpp +++ b/librerie/exercise3/list/list.cpp @@ -167,7 +167,7 @@ void List::InsertAtBack(const Data& data){ template void List::InsertAtBack(Data&& data){ if(size == 0){ - InsertAtFront(data); + InsertAtFront(std::move(data)); } else{ struct Node* last = new Node(std::move(data)); diff --git a/librerie/exercise3/queue/vec/queuevec.cpp b/librerie/exercise3/queue/vec/queuevec.cpp index 42f6857..a76066f 100755 --- a/librerie/exercise3/queue/vec/queuevec.cpp +++ b/librerie/exercise3/queue/vec/queuevec.cpp @@ -37,7 +37,7 @@ QueueVec::QueueVec(const QueueVec& toCopy){ template QueueVec::QueueVec(QueueVec&& toMove) noexcept{ - Clear(); + Clear(); // the moved Queue will be in a consistent state std::swap(Elements, toMove.Elements); std::swap(rear, toMove.rear); std::swap(front, toMove.front); @@ -140,7 +140,7 @@ bool QueueVec::Empty() const noexcept{ template ulong QueueVec::Size() const noexcept{ - //if(size == 0) return 0; // this won't ever get executed, it's here just in case + //if(size == 0) return 0; // this won't ever get executed, it's here just in case return ((rear + size) - front) % size; } diff --git a/librerie/exercise3/stack/lst/stacklst.cpp b/librerie/exercise3/stack/lst/stacklst.cpp index f1f24d8..a9b6cdc 100755 --- a/librerie/exercise3/stack/lst/stacklst.cpp +++ b/librerie/exercise3/stack/lst/stacklst.cpp @@ -52,7 +52,7 @@ void StackLst::Push(const Data& element){ template void StackLst::Push(Data&& element) noexcept{ - List::InsertAtFront(element); + List::InsertAtFront(std::move(element)); } template diff --git a/librerie/exercise3/stack/vec/stackvec.cpp b/librerie/exercise3/stack/vec/stackvec.cpp index eabb6ad..ca711d3 100755 --- a/librerie/exercise3/stack/vec/stackvec.cpp +++ b/librerie/exercise3/stack/vec/stackvec.cpp @@ -44,7 +44,7 @@ StackVec& StackVec::operator=(const StackVec& copyFrom){ template StackVec& StackVec::operator=(StackVec&& moveFrom) noexcept{ Vector::operator=(std::move(moveFrom)); - stackSize = moveFrom.Size(); + std::swap(stackSize, moveFrom.stackSize); return *this; }