| kohline (2) | |
|
hi i"m new to c++ and became a program to insert some stuff. there is a class called Cluster those clusters appear mostly as vector<Cluster> if i define Cluster cluster;there is something like cluster.size()which will give me the number of elements inside my cluster. i now want to sort the vector<Cluster> with respect to the number of elements in my cluster. afterwards i want to pick only the ones with less than 5 elements, and erase them from vector<Cluster>. afterwards i have to access the vector<Cluster> but i dont want the vector<Cluster> to be accessed from smallest to largest cluster. are there some ideas how to achieve this? thanks a lot kohline | |
|
|
|
| Mitsakos (343) | ||
|
You can overload the operators "<", ">", "==" for your class and use the sort() function from the algorithms... Using the "<" operator you can find which one has less than 5 elemnts and erase it.
Use random() to shuffle it... | ||
|
|
||
| kohline (2) | |
| thanks a lot. i'll try this out and see how far i can get. | |
|
|
|