I am looking for a special class of templates, I hope either a QT template or a standalone open source library. This class of templates is intended to be used as a container for a set of objects. Each object in the set has an integer weight function, but the weight function itself is arbitrary. It can be evenly from 10 to 100 or vary unevenly from 1000 to 10000 or be a constant value.
The template will save a list of objects sorted by this weight (arbitrarily allowing communications). This will allow me to quickly get the object with the nth highest weight from the list, in order and not in value (random access using an integer, such as QList). The template also allows me to quickly add and remove arbitrary elements, while maintaining a list sorted by weight (e.g. QMap).
Just quickly finding objects in order of magnitude would be enough for my purposes - IE, finding the 1st, 10th, 100th, 1000th and so on elements in my ordered list would be enough.
I could implement a data structure like this myself (as an array of lists of increasing size or as a modified binary tree with the number of n elements below each node). But to solve the problem it is better to use a standard, publicly available well-documented template. I would prefer to avoid STL, but if there is an STL solution, I would be interested.
Change . I am looking for at least orders - not only the first, but the 1st, 10th, 100th, ordered by weight (internal ordering of the heap data structure would be great, but I don't see any functions that directly access this). I see that the STL provides a "random access iterator", but after swapping through enough documentation, I still cannot find whether this iterator will give the nth value without requiring sorting the list for each call - indeed, my vague impression what would that be. STL also provides an nth item function, but it seems relatively expensive if you call it for every access to the list.
Edit2:
, QMap it2 = it.begin() + 1000; ( QT):
:: operator + (int j) Const
j . ( j , .)
j .
. -().