Sunday 15 May 2011

c++ - QLinkedList operator+ efficiency -


I'm looking to combine myself with QLinkedLists , so I have a question about QT's efficiency Concerned in QLinkedList :: operator + (const QLinkedList & lt; T & gt; and other) const

I for operator + Tried to see the source code, but I could not understand much about it. I have asked for help on it.

What is the operator + () operator being used to add two types of two codes? Whether the Iterator is omitted in the second list in the implementation, on the other hand there is no penalties in the list altogether operator + ()?

I have found this:

  template & Lt; Typename T & gt; QLinkedList & LT; T & gt; QLinkedList & lt; T & gt; :: Operator + (Consta Linkedlist & lt; T & gt; & amp; l) Const {QLinkedList & lt; T & gt; N = this; N + = l; Return n; }   

Then it copies the entire list, uses the operator + = () and returns the new list.

But I'm worried:

If you are trying to merge large listings ... I will personally use the std :: list . In other words, there are many cases where you do not need to keep a copy of both the lists (subsets) and this is the place where there are penalties.

  QList a, b, c; // ... e.t.c. Eclipses & amp; Great size c = a + b to grow b;   

By the above example, if you have a & amp; Around B, then this is a necessary cost to create a new list from subset, but if you do not need any more amp; After B, the list is made C ... then the operator's use + is not optimal and certainly - for the small lists it's all trivial.

This study :: list container is.

For the std :: list, I would like to use something. I can not find anything for this, but as I said earlier, I favor STL containers in my code.

No comments:

Post a Comment