On Friday 13 June 2008 12:53:42 Andre Haupt wrote:
> I have x/y measurement data which could be seen as a key/value pair, x
> being the key. e.g.
> x 3.0 4.0 5.0
> y 47.11 32.3 24.3
> This simplified table can be several 1000 items long. On more
> requirement is, that i must be able to linearily interpolate along
> the table, i.e. get the y value for x = 3.33 in the above example.
> All i know about this table, is that x is ordered. It can start/end with
> any x-value.
> For now, i am using a QList<struct xy> approach. If i want to know the
> interpolated y-value for a given x, i have to walk along the list. The
> downside is, that this takes longer, the bigger x is.
> Are there any alternatives that would allow to quickly find the
> interpolation limits?
Totally depends on your use case.
QHash is pretty quick with random access on large keys.
If you really really need every microsecond of performance gain, you might
want to implement your own data structure. possibly a linked list with a
black/red tree kind of aproach where you would search for the key from fixed
entry points depending on the first digit or something like that. Well,.. but
QHash should be enought, really.
Arvid Ephraim Picciani
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/