# WeakHashList

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-weakhashlist/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct WeakHashList<T: ?Sized + 'static>
```

A list of weakly referenced items, compared by identity.

Up to `DEFAULT_ARRAY_SIZE` items are kept in
an array; beyond that the list switches to a dictionary that counts how
many times each item was added.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L12)

## Members

- [`DEFAULT_ARRAY_SIZE`](#assoc_const-default_array_size)
- [`new`](#function-new)
- [`is_empty`](#function-is_empty)
- [`need_compact`](#function-need_compact)
- [`add`](#function-add)
- [`remove`](#function-remove)
- [`compact`](#function-compact)
- [`return_to_shared_pool`](#function-return_to_shared_pool)
- [`get_alive`](#function-get_alive)

<a id="assoc_const-default_array_size"></a>

### DEFAULT_ARRAY_SIZE

```rust
const DEFAULT_ARRAY_SIZE: usize
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L148)

<a id="function-new"></a>

### new

```rust
fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L150)

<a id="function-is_empty"></a>

### is_empty

```rust
fn is_empty(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L154)

<a id="function-need_compact"></a>

### need_compact

```rust
fn need_compact(self: &Self) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L161)

<a id="function-add"></a>

### add

```rust
fn add(self: &mut Self, item: &Rc<T>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L165)

<a id="function-remove"></a>

### remove

```rust
fn remove(self: &mut Self, item: &Rc<T>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L204)

<a id="function-compact"></a>

### compact

```rust
fn compact(self: &mut Self)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L250)

<a id="function-return_to_shared_pool"></a>

### return_to_shared_pool

```rust
fn return_to_shared_pool(list: Vec<Rc<T>>)
```

Clears `list` and keeps it for a later `get_alive`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L265)

<a id="function-get_alive"></a>

### get_alive

```rust
fn get_alive(self: &mut Self, factory: Option<&dyn Fn() -> Vec<Rc<T>>>) -> Option<Vec<Rc<T>>>
```

The items that are still alive, or `None` if there are none. The list
comes from `factory` when given, else from the shared pool.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/weak_hash_list.rs#L292)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Default`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
