---
title: llarp::dht::Bucket

---

# llarp::dht::Bucket



 [More...](#detailed-description)

## Public Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[SetIntersector](Classes/structllarp_1_1dht_1_1Bucket_1_1SetIntersector.md)**  |

## Public Types

|                | Name           |
| -------------- | -------------- |
| using std::map< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md), Val_t, [XorMetric](Classes/structllarp_1_1dht_1_1XorMetric.md) > | **[BucketStorage_t](Classes/structllarp_1_1dht_1_1Bucket.md#using-bucketstorage-t)**  |
| using std::function< uint64_t()> | **[Random_t](Classes/structllarp_1_1dht_1_1Bucket.md#using-random-t)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[Bucket](Classes/structllarp_1_1dht_1_1Bucket.md#function-bucket)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & us, Random_t r) |
| util::StatusObject | **[ExtractStatus](Classes/structllarp_1_1dht_1_1Bucket.md#function-extractstatus)**() const |
| size_t | **[size](Classes/structllarp_1_1dht_1_1Bucket.md#function-size)**() const |
| bool | **[GetRandomNodeExcluding](Classes/structllarp_1_1dht_1_1Bucket.md#function-getrandomnodeexcluding)**([Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & result, const std::set< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) > & exclude) const |
| bool | **[FindClosest](Classes/structllarp_1_1dht_1_1Bucket.md#function-findclosest)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & target, [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & result) const |
| bool | **[GetManyRandom](Classes/structllarp_1_1dht_1_1Bucket.md#function-getmanyrandom)**(std::set< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) > & result, size_t N) const |
| bool | **[FindCloseExcluding](Classes/structllarp_1_1dht_1_1Bucket.md#function-findcloseexcluding)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & target, [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & result, const std::set< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) > & exclude) const |
| bool | **[GetManyNearExcluding](Classes/structllarp_1_1dht_1_1Bucket.md#function-getmanynearexcluding)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & target, std::set< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) > & result, size_t N, const std::set< [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) > & exclude) const |
| void | **[PutNode](Classes/structllarp_1_1dht_1_1Bucket.md#function-putnode)**(const Val_t & val) |
| void | **[DelNode](Classes/structllarp_1_1dht_1_1Bucket.md#function-delnode)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & key) |
| bool | **[HasNode](Classes/structllarp_1_1dht_1_1Bucket.md#function-hasnode)**(const [Key_t](Classes/structllarp_1_1dht_1_1Key__t.md) & key) const |
| template <typename Predicate \> <br>void | **[RemoveIf](Classes/structllarp_1_1dht_1_1Bucket.md#function-removeif)**(Predicate pred) |
| template <typename Visit_t \> <br>void | **[ForEachNode](Classes/structllarp_1_1dht_1_1Bucket.md#function-foreachnode)**(Visit_t visit) |
| void | **[Clear](Classes/structllarp_1_1dht_1_1Bucket.md#function-clear)**() |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| BucketStorage_t | **[nodes](Classes/structllarp_1_1dht_1_1Bucket.md#variable-nodes)**  |
| Random_t | **[random](Classes/structllarp_1_1dht_1_1Bucket.md#variable-random)**  |

## Detailed Description

```cpp
template <typename Val_t >
struct llarp::dht::Bucket;
```

## Public Types Documentation

### using BucketStorage_t

```cpp
using llarp::dht::Bucket< Val_t >::BucketStorage_t =  std::map<Key_t, Val_t, XorMetric>;
```


### using Random_t

```cpp
using llarp::dht::Bucket< Val_t >::Random_t =  std::function<uint64_t()>;
```


## Public Functions Documentation

### function Bucket

```cpp
inline Bucket(
    const Key_t & us,
    Random_t r
)
```


### function ExtractStatus

```cpp
inline util::StatusObject ExtractStatus() const
```


### function size

```cpp
inline size_t size() const
```


### function GetRandomNodeExcluding

```cpp
inline bool GetRandomNodeExcluding(
    Key_t & result,
    const std::set< Key_t > & exclude
) const
```


### function FindClosest

```cpp
inline bool FindClosest(
    const Key_t & target,
    Key_t & result
) const
```


### function GetManyRandom

```cpp
inline bool GetManyRandom(
    std::set< Key_t > & result,
    size_t N
) const
```


### function FindCloseExcluding

```cpp
inline bool FindCloseExcluding(
    const Key_t & target,
    Key_t & result,
    const std::set< Key_t > & exclude
) const
```


### function GetManyNearExcluding

```cpp
inline bool GetManyNearExcluding(
    const Key_t & target,
    std::set< Key_t > & result,
    size_t N,
    const std::set< Key_t > & exclude
) const
```


### function PutNode

```cpp
inline void PutNode(
    const Val_t & val
)
```


### function DelNode

```cpp
inline void DelNode(
    const Key_t & key
)
```


### function HasNode

```cpp
inline bool HasNode(
    const Key_t & key
) const
```


### function RemoveIf

```cpp
template <typename Predicate >
inline void RemoveIf(
    Predicate pred
)
```


### function ForEachNode

```cpp
template <typename Visit_t >
inline void ForEachNode(
    Visit_t visit
)
```


### function Clear

```cpp
inline void Clear()
```


## Public Attributes Documentation

### variable nodes

```cpp
BucketStorage_t nodes;
```


### variable random

```cpp
Random_t random;
```


-------------------------------

Updated on 2023-01-26 at 19:35:17 +0000