> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Struct UHashMap

Module: `std::collections::umap`

```rust
pub struct UHashMap<K, V, B>
{ /* private fields */ }
```

## Implementations

```rust
impl<K, V, B> UHashMap<K, V, B>
```

```rust
pub fn with_hasher(_build_hasher: B) -> Self
where
    B: BuildHasher
```

Creates a new instance of UHashMap with specified BuildHasher.

```rust
pub fn with_hasher_and_capacity(_build_hasher: B, capacity: u32) -> Self
where
    B: BuildHasher
```

```rust
pub unconstrained fn clear(&mut self)
```

Clears the map, removing all key-value entries.

```rust
pub unconstrained fn contains_key(&self, key: K) -> bool
where
    K: Hash,
    K: Eq,
    B: BuildHasher
```

Returns true if the map contains a value for the specified key.

```rust
pub unconstrained fn is_empty(&self) -> bool
```

Returns true if the map contains no elements.

```rust
pub unconstrained fn entries(&self) -> [(K, V)]
```

Returns a vector of all valid entries in this UHashMap. The length of the returned vector will always match the length of this UHashMap.

```rust
pub unconstrained fn keys(&self) -> [K]
```

Returns a vector containing all the keys within this UHashMap. The length of the returned vector will always match the length of this UHashMap.

```rust
pub unconstrained fn values(&self) -> [V]
```

Returns a vector containing all the values within this UHashMap. The length of the returned vector will always match the length of this UHashMap.

```rust
pub unconstrained fn iter_mut(&mut self, f: fn(K, V) -> (K, V))
where
    K: Eq,
    K: Hash,
    B: BuildHasher
```

For each key-value entry applies mutator function.

```rust
pub unconstrained fn iter_keys_mut(&mut self, f: fn(K) -> K)
where
    K: Eq,
    K: Hash,
    B: BuildHasher
```

For each key applies mutator function.

```rust
pub unconstrained fn iter_values_mut(&mut self, f: fn(V) -> V)
```

For each value applies mutator function.

```rust
pub unconstrained fn retain(&mut self, f: fn(K, V) -> bool)
```

Retains only the elements specified by the predicate.

```rust
pub unconstrained fn len(&self) -> u32
```

Amount of active key-value entries.

```rust
pub unconstrained fn capacity(&self) -> u32
```

Get the current capacity of the inner table.

```rust
pub unconstrained fn get(&self, key: K) -> Option<V>
where
    K: Eq,
    K: Hash,
    B: BuildHasher
```

Get the value by key. If it does not exist, returns none().

```rust
pub unconstrained fn insert(&mut self, key: K, value: V) -> bool
where
    K: Eq,
    K: Hash,
    B: BuildHasher
```

Insert key-value entry. In case key was already present, value is overridden.

Returns true if the element was newly-inserted. In other words, this returns false if the key already has a value in this map.

```rust
pub unconstrained fn remove(&mut self, key: K)
where
    K: Eq,
    K: Hash,
    B: BuildHasher
```

Removes a key-value entry. If key is not present, UHashMap remains unchanged.

## Trait implementations

```rust
impl<B, K, V> Default for UHashMap<K, V, B>
where
    B: BuildHasher,
    B: Default
```

```rust
pub fn default() -> Self
```

```rust
impl<B, K, V> Eq for UHashMap<K, V, B>
where
    K: Eq,
    K: Hash,
    V: Eq,
    B: BuildHasher
```

```rust
pub fn eq(self, other: Self) -> bool
```
