둥지/알고리즘20 가변 배열 구현 #include template class MyVector { T* Array_; size_t Size_; size_t Capacity_; public: MyVector() { Array_ = new T[2 * sizeof(T)]; Capacity_ = 2 * sizeof(T); Size_ = 0; } ~MyVector() { } size_t Size() const { return Size_; } void Release() { delete Array_; Array_ = nullptr; } void Resize() { T* TempArray_; TempArray_ = new T[Capacity_ * 2 * sizeof(T)]; for (size_t i = 0; i < Size_; ++i) { TempArr.. 2023. 2. 9. 배열 구현 #include constexpr int INVALID_INDEX = -1; constexpr int MAX_COUNT = 101; template class MyArray { T Array_[MAX_COUNT]; size_t Size_; public: void Insert(size_t _Index, T _Data) { if (0 == _Index) { Array_[_Index] = _Data; ++Size_; return; } for (size_t i = Size_; i > _Index; --i) { Array_[i] = Array_[i - 1]; } Array_[_Index] = _Data; ++Size_; } void OrderlyRemove(size_t _Index) { for (size_t i .. 2023. 2. 8. 이전 1 2 3 4 다음