std::queue::size(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay bestie, welcome to std::queue::size(3) from the C++ Standard Libary πŸ’– (yes, that exact manual name, typo and all, we're keeping it). This page is about std::queue::size β€” literally std::queue::size β€” the member function that tells you how many elements are hanging out in your container adaptor. No cap, that's the whole assignment. ✨


πŸ¦‹ Synopsis πŸ¦‹

size_type size() const;

Returns the number of elements in the container adaptor. Equivalent to return c.size().

That's the vibe. Short, iconic, to the point. πŸ’…


πŸŽ€ Parameters πŸŽ€

  • (none) β€” zero args, bestie. Not a single parameter in sight πŸ™ˆ

✨ Return value ✨

The number of elements in the container adaptor. That's it. That's the tea. πŸ“


πŸ”₯ Complexity πŸ”₯

Constant. No scaling drama, just constant energy. ⭐


🌈 Example 🌈

Run this code, bestie:

// Run this code

#include <algorithm>
#include <cassert>
#include <queue>

int main()
{
    std::queue<int> queue;

    assert(queue.size() == 0);

    const int count = 8;

    for (int i = 0; i != count; ++i)
        queue.push(i);

    assert(queue.size() == count);
}

πŸ‘‘ See also πŸ‘‘

  • empty β€” checks whether the container adaptor is empty (public member function)
  • size
  • ssize β€” returns the size of a container or array (C++17) (function template) (C++20)

source is http://cppreference.com, version/date is 2024.06.10 β€” and that's the whole page, bestie, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from