Answer the question
In order to leave comments, you need to log in
How to store records from the VK wall?
Good afternoon! I am making a small mobile application and it became necessary to get a list of records with all attachments from the VK wall.
Comes to mind QList <QList <QMap <QString, QString> > >
.
That is:
Text, objects (music, pictures, video) are stored each in a separate QMap <QString, QString>
, from this it turns out that each entry from the wall is QList <QMap <QString, QString> >
, and, accordingly, the list of entries is QList <QList <QMap <QString, QString> > >
.
Isn't it very cumbersome and resource-intensive in terms of performance?
Answer the question
In order to leave comments, you need to log in
Not cumbersome and not resource-intensive (especially in C ++ 11 - by the way, Qt will soon abandon 03 altogether).
However, I would make structs from one element in such heaps. Something like
struct Comment {
QMap<QString, QString> objects;
};
struct Post {
QList<Comment> comments;
};
objects
and what do you need this "string typing" for?
The performance of containers depends on the operations that are performed on them.
The List is fast to insert and quickly traverse in order, but if you need to access an element in the middle of the container, it will take a long time. In a normal Map, access complexity grows logarithmically with size - HashMap is spared this shortcoming. Mercury13 correctly tells you that data structures should be removed for class abstraction:
class VKWall {
public:
Add(VKWallPost&& wp);
private:
QList<VKWallPost> m_posts;
};
stuct vkobj {unsigned wallpost_id, char[255] key, char[255] value};
QVector<vkobj> m_posts;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question