T
tim.lino
Hello,
I would like to use C++ STL to store a set of Object's which is as
follows:
class Object
{
public:
int value;
......
}
I need to perform the following actions:
1. Sort Objects in the increasing order of their "value".
2. After sorting, I need to randomly access some of the Objects.
As I know, vector is very efficient in random access. However, sorting
vector of size n takes O(nlog n) time which is not good.
Is there a good data structure (or a combination of some) such that it
is efficient in random access and sorting?
Thank You.
I would like to use C++ STL to store a set of Object's which is as
follows:
class Object
{
public:
int value;
......
}
I need to perform the following actions:
1. Sort Objects in the increasing order of their "value".
2. After sorting, I need to randomly access some of the Objects.
As I know, vector is very efficient in random access. However, sorting
vector of size n takes O(nlog n) time which is not good.
Is there a good data structure (or a combination of some) such that it
is efficient in random access and sorting?
Thank You.