[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppDeque

(C++) std::deque

(pronounciation: 'deck')

A STL container class that supports random access iterators and efficient insertion/deletion at both beginning and end.

Very similar to std::vector.

About std::deque<bool>

Avoid std::vector<bool> [1]. One of the alternatives is std::deque<bool>. That this works correctly can be seen by this example code:

  1. include <iostream>
  2. include <deque>
int main() { std::deque<bool> d; d.push_back(0); d.push_back(69); d.push_back(-69); d.push_back(123); d.push_back(255); while (!d.empty()) { std::cout << d.back() << std::endl; d.pop_back(); } std::cin.get(); return 0; }


Output:
1
1
1
1
0


Note, however, that using a std::vector in this example yields the same correct results.

Links

Reference

  • 1) Scott Meyers, Effective STL.


last edited (November 15, 2006) by bilderbikkel, Number of views: 2899, Current Rev: 5 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.