# EnumerableSet

## **Functions and Usage**

**EnumerableSet** is a public library defined by OpenZeplin project team in MIT License, which consists of **an object set** and a set of methods that can be used to store non-repetitive enumerable set in three data types, Bytes32, Address, and Uint. It can determine whether an element is contained in a set based on its value, and also quickly query the total number of elements in the set, a list of all the elements, and even can query the element value by its number.

## **Members and Attributes**

The main members of the **Enumerable Set** include the **Enumerable Set Object** and the set objects of Byte 32 set, Address set, and Uint set derived from its kernel.

### **Enumerable Set**

The object in **Enumerable Set** consists of a variable-length array with a 32-bit and an "element value -> index number" mapping. This structure not only allows you to quickly get the total number of elements in the set and the list of all elements, but also allows you to quickly query the corresponding array element number (index-1) from the mapping based on the element value, so you can determine whether the element has been contained in the set (index>0), and also allows you to quickly locate and delete specific array when deleting an element.

<figure><img src="/files/0syxJTH5UPihc1NhLyUx" alt=""><figcaption><p>The Structure of Enumerable Set Repo</p></figcaption></figure>

#### Attribute List of Set Object

| Attribute | Commercial and Legal meaning            |
| --------- | --------------------------------------- |
| \_values  | a variable-length array with bytes 32   |
| \_indexes | "element value -> index number" mapping |

## **Query API**

The query API well describes the function and usage of the **enumerable set repo** in the whole system, as shown in the following list.

| API      | Commercial and Legal Meaning                            |
| -------- | ------------------------------------------------------- |
| contains | Query whether the element has been contained in the set |
| length   | Get the total number of elements in the set.            |
| at       | Get the element values according to array number        |
| values   | Get the list of all elements.                           |

## Source Code

#### [EnumerableSet](https://github.com/paul-lee-attorney/comboox/blob/master/contracts/lib/EnumerableSet.sol)


---

# Agent Instructions: 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://comboox.gitbook.io/whitepaper-en/technical-brochure/structure-and-components/enumerableset.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.
