lasd/librerie/exercise2/stack/lst/stacklst.cpp

81 lines
1.8 KiB
C++
Raw Normal View History

2021-04-10 13:34:50 +02:00
namespace lasd {
/* ************************************************************************** */
2021-04-12 22:04:22 +02:00
// Constructors
template <typename Data>
2021-04-20 18:16:51 +02:00
StackLst<Data>::StackLst(const LinearContainer<Data>& linear)
: List<Data>(linear){}
2021-04-19 12:32:33 +02:00
template <typename Data>
2021-04-20 18:16:51 +02:00
StackLst<Data>::StackLst(const StackLst& stcklist)
: List<Data>(stcklist){}
2021-04-12 22:04:22 +02:00
template <typename Data>
2021-04-20 18:16:51 +02:00
StackLst<Data>::StackLst(StackLst&& stcklist) noexcept
: List<Data>(std::move(stcklist)){}
2021-04-12 22:04:22 +02:00
// Destructor
2021-04-19 12:32:33 +02:00
template <typename Data>
StackLst<Data>::~StackLst(){
2021-04-12 22:04:22 +02:00
Clear();
}
2021-04-19 12:32:33 +02:00
template <typename Data>
StackLst<Data>& StackLst<Data>::operator=(const StackLst& copyFrom){
2021-04-20 18:16:51 +02:00
List<Data>::operator=(copyFrom);
2021-04-12 22:04:22 +02:00
return *this;
}
2021-04-19 12:32:33 +02:00
template <typename Data>
StackLst<Data>& StackLst<Data>::operator=(StackLst&& moveFrom) noexcept{
2021-04-20 18:16:51 +02:00
List<Data>::operator=(std::move(moveFrom));
2021-04-12 22:04:22 +02:00
return *this;
}
2021-04-19 12:32:33 +02:00
template <typename Data>
bool StackLst<Data>::operator==(const StackLst& stcklist) const noexcept{
2021-04-12 22:04:22 +02:00
return List<Data>::operator==(stcklist);
}
2021-04-19 12:32:33 +02:00
template <typename Data>
bool StackLst<Data>::operator!=(const StackLst& stcklist) const noexcept{
2021-04-12 22:04:22 +02:00
return List<Data>::operator!=(stcklist);
}
// Specific member functions (inherited from Stack)
template <typename Data>
2021-04-19 12:32:33 +02:00
void StackLst<Data>::Push(const Data& element){
2021-04-12 22:04:22 +02:00
List<Data>::InsertAtFront(element);
}
template <typename Data>
2021-04-19 12:32:33 +02:00
void StackLst<Data>::Push(Data&& element) noexcept{
2021-04-12 22:04:22 +02:00
List<Data>::InsertAtFront(element);
}
template <typename Data>
2021-04-19 12:32:33 +02:00
Data& StackLst<Data>::Top() const{
2021-04-12 22:04:22 +02:00
return List<Data>::Front();
}
template <typename Data>
2021-04-19 12:32:33 +02:00
void StackLst<Data>::Pop(){
2021-04-12 22:04:22 +02:00
List<Data>::RemoveFromFront();
}
template <typename Data>
2021-04-19 12:32:33 +02:00
Data StackLst<Data>::TopNPop(){
2021-04-12 22:04:22 +02:00
return List<Data>::FrontNRemove();
}
template <typename Data>
2021-04-19 12:32:33 +02:00
void StackLst<Data>::Clear(){
2021-04-12 22:04:22 +02:00
List<Data>::Clear();
}
2021-04-10 13:34:50 +02:00
/* ************************************************************************** */
}