Results 1 to 9 of 9

Thread: Remove first n elements from QList

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove first n elements from QList

    T QList::takeFirst ()

    Removes the first item in the list and returns it.
    This is the same as takeAt(0).
    This operation is very fast (constant time), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list.

    If you don't use the return value, removeFirst() is more efficient.

    See also takeLast(), takeAt(), and removeFirst().
    So it's pretty clear.

    Regards

  2. The following user says thank you to marcel for this useful post:

    pakulo (2nd June 2007)

  3. #2
    Join Date
    May 2007
    Posts
    32
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Remove first n elements from QList

    Thanks a lot!

  4. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Remove first n elements from QList

    It preallocates extra space? And here I thought QList was a linked list. Such a list wouldn't need preallocation to grow at both ends. But now I see. There is also a QLinkedList class. But since there is also a QVector class (which would use a dynamic array, I guess), how is QList implemented?
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Similar Threads

  1. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43
  2. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.