ORIGINAL
Loading...
Searching...
No Matches
baseList.h
Go to the documentation of this file.
1#ifndef BASELIST_H
2#define BASELIST_H
3#include "serial.h"
4
5namespace original {
6
16
42 template <typename TYPE, typename ALLOC>
43 class baseList : public serial<TYPE, ALLOC> {
44 protected:
51 using serial<TYPE, ALLOC>::serial;
52 public:
58 virtual void add(const TYPE& e);
59
66 virtual TYPE remove(const TYPE& e);
67
75 virtual void clear();
76
83 virtual void push(integer index, const TYPE& e) = 0;
84
91 virtual TYPE pop(integer index) = 0;
92
98 virtual void pushBegin(const TYPE& e) = 0;
99
105 virtual TYPE popBegin() = 0;
106
112 virtual void pushEnd(const TYPE& e) = 0;
113
119 virtual TYPE popEnd() = 0;
120 };
121}
122
123 template <typename TYPE, typename ALLOC>
124 auto original::baseList<TYPE, ALLOC>::add(const TYPE &e) -> void
125 {
126 this->pushEnd(e);
127 }
128
129 template <typename TYPE, typename ALLOC>
130 auto original::baseList<TYPE, ALLOC>::remove(const TYPE& e) -> TYPE
131 {
132 const integer index = this->indexOf(e);
133 return this->pop(index);
134 }
135
136 template <typename TYPE, typename ALLOC>
138 while (!this->empty()) {
139 this->popEnd();
140 }
141 }
142
143#endif //BASELIST_H
Base class for variable-size serial containers.
Definition baseList.h:43
virtual TYPE pop(integer index)=0
Removes an element from a specific index.
virtual void pushBegin(const TYPE &e)=0
Inserts an element at the beginning of the list.
virtual TYPE popBegin()=0
Removes an element from the beginning of the list.
virtual TYPE popEnd()=0
Removes an element from the end of the list.
virtual void clear()
Removes all elements.
Definition baseList.h:137
virtual TYPE remove(const TYPE &e)
Removes an element from the list.
Definition baseList.h:130
virtual void add(const TYPE &e)
Adds an element to the end of the list.
Definition baseList.h:124
virtual void push(integer index, const TYPE &e)=0
Inserts an element at a specific index.
virtual void pushEnd(const TYPE &e)=0
Inserts an element at the end of the list.
bool empty() const
Checks if the container is empty.
Definition container.h:155
Abstract base class for sequential containers with index-based access.
Definition serial.h:34
virtual u_integer indexOf(const TYPE &e) const =0
Finds the index of the specified element.
Main namespace for the project Original.
Definition algorithms.h:21
std::int64_t integer
64-bit signed integer type for arithmetic operations
Definition config.h:15
Defines an abstract base class for sequential containers with index-based access.