Kylin/DataStructure/StaticArrayList.h

27 lines
617 B
C
Raw Normal View History

2023-12-27 10:29:16 +08:00
#ifndef STATICSEQLIST_H
#define STATICSEQLIST_H
#include "ArrayList.h"
namespace Kylin {
template <typename T, size_t N>
class StaticArrayList : public ArrayList<T> {
public:
StaticArrayList() { this->m_array = m_space; }
StaticArrayList(const StaticArrayList &other) {
this->m_array = m_space;
for (size_t i = 0; i < other.m_size; i++) {
m_space[i] = other.m_space[i];
this->m_size++;
}
}
virtual size_t capacity() const noexcept { return N; }
private:
T m_space[N];
};
} // namespace Kylin
#endif // STATICSEQLIST_H