B
Blue Ocean
How do I do it?
I'm doing a practice problem which includes me implementing a set of
ints as a class. I don't want to use vector because that would be
cheating. I don't want to spend enough time on it to make it a
treeset, so I'm just gonna do an array set. It's gonna have a static
const int default size, and it's going to have a member private int
threshold. Once the size of the set passes the threshold, the next
call to any operation on it will resize it to double whatever its
current size is.
So the only difficulty is, how do I resize the array? I know that I
could use c's malloc and realloc if I included the libraries, but I
don't know if this is the right way to do things in C++.
Any help is much appreciated, as always.
I'm doing a practice problem which includes me implementing a set of
ints as a class. I don't want to use vector because that would be
cheating. I don't want to spend enough time on it to make it a
treeset, so I'm just gonna do an array set. It's gonna have a static
const int default size, and it's going to have a member private int
threshold. Once the size of the set passes the threshold, the next
call to any operation on it will resize it to double whatever its
current size is.
So the only difficulty is, how do I resize the array? I know that I
could use c's malloc and realloc if I included the libraries, but I
don't know if this is the right way to do things in C++.
Any help is much appreciated, as always.