Filter
This interface defines a filter that can check for the presence of an ID and add new IDs. It provides methods to determine if an ID has been seen previously and to add an ID, potentially evicting an older item.
Methods
Contains()
@classmethod
def Contains(
ctx: context.Context,
id: []byte
) - > bool
Contains returns a True if the id was previously seen or false otherwise It may return a false, even if a item may have previously occurred.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, allowing for cancellation and timeouts. |
| id | []byte | The identifier to check for previous occurrence in the filter. |
Returns
| Type | Description |
|---|---|
bool | True if the id was previously seen, False otherwise. Note that it may return False even if an item has occurred. |
Add()
@classmethod
def Add(
ctx: context.Context,
id: []byte
) - > bool
Adds the element id to the Filter and returns if a previous object was evicted in the process
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, allowing for cancellation and timeouts. |
| id | []byte | The identifier to add to the filter. |
Returns
| Type | Description |
|---|---|
bool | True if an existing object was evicted from the filter during the add operation, False otherwise. |