> For the complete documentation index, see [llms.txt](https://blog.gomchik.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.gomchik.com/tech/c++/unordered_set.md).

# Unordered Set

```cpp
#include <unordered_set>
  
unordered_set<int> s;                       // create an unordered_set of integers
unordered_set<int> s({4, 3, 9, 2, 0, 6});   // create an unordered_set with few initial elements
     
cout << s.size() << endl;                   // number of elements in unordered_set
s.insert(123);                              // add element to unordered_set
s.erase(444);                               // erase an element from the unordered_set
s.clear();                                  // remove all the elements from the unordered_set
        

// search for an element
if (s.find(444) != s.end()) {
    // It means 444 exists in the set
} 

// iterate over all elements
for(unordered_set<int>::iterator it = s.begin(); it != s.end(); it++) {
    cout << *it << endl;
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.gomchik.com/tech/c++/unordered_set.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
