QCustomPlot Discussion and Comments

graph->data()->lowerBound(x);Return to overview

I was using Qcustomplot Version: 1.3.2, which supports data map.
const QCPDataMap *dm = graph->data();
With a map, I can find a closer iterator by calling lowerBound().
QCPDataMap::const_iterator it = dm->lowerBound(x);

But, in Version: 2.0.0-beta, the map does not exist any more.
Is there a way to find a closer iterator, like lowerBound()?
Thanks,

try the findBegin and findEnd methods of the new data container.

On way to get the last data of your graph you'd be :

(graph(aGraphIdx)->data().data()->constEnd()-1)->key;

findBegin and findEnd are not what I want.

For example, in this map:
QMap<int, QString> map;
map.insert(1, "one");
map.insert(5, "five");
map.insert(10, "ten");

what I want is:
map.lowerBound(2); // returns iterator to (5, "five")
where 5 is the closest key, which is no-less-than given number,2.

But isn't that exactly what findBegin(5, false) does?

http://www.qcustomplot.com/documentation/classQCPDataContainer.html#a2ad8a5399072d99a242d3a6d2d7e278a

This is exactly what it does Isso !

(think this is solved :P)

Yes, both of you are right. I was wrongly token findBegin as finding the beginning of the data range. Sorry about that. Thank.

also there is a function called qLowerBound(). it takes in an iterator to the begin and end and a value... works for everything with a random access iterator in logN time. as long as there is a less than function for the template class.