Library 2

This commit is contained in:
Alessandro Ferro 2021-06-09 09:31:27 +02:00
parent 05da596510
commit 2161904478
4 changed files with 5 additions and 5 deletions

View File

@ -167,7 +167,7 @@ void List<Data>::InsertAtBack(const Data& data){
template <typename Data> template <typename Data>
void List<Data>::InsertAtBack(Data&& data){ void List<Data>::InsertAtBack(Data&& data){
if(size == 0){ if(size == 0){
InsertAtFront(data); InsertAtFront(std::move(data));
} }
else{ else{
struct Node* last = new Node(std::move(data)); struct Node* last = new Node(std::move(data));

View File

@ -37,7 +37,7 @@ QueueVec<Data>::QueueVec(const QueueVec& toCopy){
template <typename Data> template <typename Data>
QueueVec<Data>::QueueVec(QueueVec&& toMove) noexcept{ QueueVec<Data>::QueueVec(QueueVec&& toMove) noexcept{
Clear(); Clear(); // the moved Queue will be in a consistent state
std::swap(Elements, toMove.Elements); std::swap(Elements, toMove.Elements);
std::swap(rear, toMove.rear); std::swap(rear, toMove.rear);
std::swap(front, toMove.front); std::swap(front, toMove.front);

View File

@ -52,7 +52,7 @@ void StackLst<Data>::Push(const Data& element){
template <typename Data> template <typename Data>
void StackLst<Data>::Push(Data&& element) noexcept{ void StackLst<Data>::Push(Data&& element) noexcept{
List<Data>::InsertAtFront(element); List<Data>::InsertAtFront(std::move(element));
} }
template <typename Data> template <typename Data>

View File

@ -44,7 +44,7 @@ StackVec<Data>& StackVec<Data>::operator=(const StackVec<Data>& copyFrom){
template <typename Data> template <typename Data>
StackVec<Data>& StackVec<Data>::operator=(StackVec<Data>&& moveFrom) noexcept{ StackVec<Data>& StackVec<Data>::operator=(StackVec<Data>&& moveFrom) noexcept{
Vector<Data>::operator=(std::move(moveFrom)); Vector<Data>::operator=(std::move(moveFrom));
stackSize = moveFrom.Size(); std::swap(stackSize, moveFrom.stackSize);
return *this; return *this;
} }