std::priority_queue::size(3)

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

okay so bestie, welcome to the C++ Standard Libary manual, section 3 β€” this is the page for std::priority_queue::size, and we’re gonna make it make sense πŸ’–

πŸ’… NAME πŸ’…

std::priority_queue::size - std::priority_queue::size β€” yes, the name really said β€œI’m my own twin” and honestly? iconic.


✨ Synopsis ✨

size_type size() const;

It returns the number of elements in the container adaptor. Equivalent to return c.size(). no cap, that’s the whole move 🫢

πŸŽ€ Parameters πŸŽ€

  • (none) β€” literally zero args, bestie. not a single one. πŸ’€

🌸 Return value 🌸

The number of elements in the container adaptor. that’s it, that’s the tea πŸ“

πŸ¦‹ Complexity πŸ¦‹

Constant. lowkey refreshing, fr fr ✨

🧚 Example 🧚

this snippet is giving β€œrun me and see” energy:

// Run this code

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

int main()
{
    std::priority_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)

mwah πŸ’‹ source/version: http://cppreference.com, date: 2024.06.10, page: std::priority_queue::size(3) β€” bestie, you ate this manual page up, periodt πŸŽ€πŸ’œ

πŸ“¦ where this page comes from