Skip to content
On this page

d65_q2a_no_move.cpp

cpp
#pragma region student.h
#ifndef __STUDENT_H_
#define __STUDENT_H_

#include <algorithm>

template <typename T>
T& CP::vector_no_move<T>::operator[](int idx) {
    auto it = std::upper_bound(aux.cbegin(), aux.cend(), idx);
    it--;
    return mData[it - aux.cbegin()][idx - *it];
}

template <typename T>
void CP::vector_no_move<T>::expand_hook() {
    // your code here
    // you MAY need this function

    // aux[i] = starting index of mData[i]

    if (aux.size() == 0) {
        aux.push_back(0);
    } else {
        aux.push_back(aux.back() + mData[aux.size() - 1].size());
    }
}

#endif
#pragma endregion student.h

See on GitHub

Last Updated: 15/1/2567 13:25:21 (UTC+7)

Released under the MIT License