它在这里说
无界数组类似于std :: vector,因为它的大小可以超过任何固定边界.然而,unbounded_array旨在实现最佳性能.因此,unbounded_array不像std :: vector那样对序列进行建模.
这是什么意思?
我正在尝试实现一个无界数组:什么是无界数组?
本页更多细节:http: //www.cs.cmu.edu/~fp/courses/15122-s11/lectures/12-ubarrays.pdf
这是代码:
#include <iostream>
#include <cstdlib>
using namespace std;
class UBArray
{
public:
int *arr, *arrN, j, *pos; //Initial array is arr. The position of arr is stored in pos. arrN is the new array created when size = limit.
int size, limit; //size is the current size of the array and limit is the total size available untill a new array is created.
UBArray()
{
size = 0;
limit = 10;
arr = new …Run Code Online (Sandbox Code Playgroud)