`#[repr(transparent)]pub struct Bitset { /* private fields */ }`

## Expand description

A `Bitset`

represents a set of unsigned integers.

Another name for this data structure is “bitmap”.

The current implementation is based on roaring bitmaps.

A bitset allows adding a set of integers and provides support for set operations
like unions, intersections and checks for equality or if a value is contained
in the set. `Bitset`

also contains various functions to query metadata about
the bitset, such as the minimum or maximum values or its size.

The fastest way to iterate values in a bitset is `BitsetIter`

.

The main use case for `Bitset`

is implementing complex selections for
`SelectionModel`

.

## Implementations§

source§### impl Bitset

### impl Bitset

source#### pub fn add_range_closed(&self, first: u32, last: u32)

#### pub fn add_range_closed(&self, first: u32, last: u32)

#### pub fn copy(&self) -> Bitset

source#### pub fn difference(&self, other: &Bitset)

#### pub fn difference(&self, other: &Bitset)

Sets @self to be the symmetric difference of @self and @other.

The symmetric difference is set @self to contain all values that were either contained in @self or in @other, but not in both. This operation is also called an XOR.

It is allowed for @self and @other to be the same bitset. The bitset will be emptied in that case.

`other`

the `Bitset`

to compute the difference from

source#### pub fn maximum(&self) -> u32

#### pub fn maximum(&self) -> u32

Returns the largest value in @self.

If @self is empty, 0 is returned.

##### Returns

The largest value in @self

source#### pub fn minimum(&self) -> u32

#### pub fn minimum(&self) -> u32

Returns the smallest value in @self.

If @self is empty, `G_MAXUINT`

is returned.

##### Returns

The smallest value in @self

source#### pub fn size(&self) -> u64

#### pub fn size(&self) -> u64

Gets the number of values that were added to the set.

For example, if the set is empty, 0 is returned.

Note that this function returns a `guint64`

, because when all
values are set, the return value is `G_MAXUINT + 1`

. Unless you
are sure this cannot happen (it can’t with `GListModel`

), be sure
to use a 64bit type.

##### Returns

The number of values in the set.

source#### pub fn size_in_range(&self, first: u32, last: u32) -> u64

#### pub fn size_in_range(&self, first: u32, last: u32) -> u64

Gets the number of values that are part of the set from @first to @last (inclusive).

Note that this function returns a `guint64`

, because when all values are
set, the return value is `G_MAXUINT + 1`

. Unless you are sure this cannot
happen (it can’t with `GListModel`

), be sure to use a 64bit type.

`first`

the first element to include

`last`

the last element to include

##### Returns

The number of values in the set from @first to @last.

source#### pub fn remove_all(&self)

#### pub fn remove_all(&self)

Removes all values from the bitset so that it is empty again.

source#### pub fn remove_range(&self, start: u32, n_items: u32)

#### pub fn remove_range(&self, start: u32, n_items: u32)

source#### pub fn remove_range_closed(&self, first: u32, last: u32)

#### pub fn remove_range_closed(&self, first: u32, last: u32)

source#### pub fn shift_left(&self, amount: u32)

#### pub fn shift_left(&self, amount: u32)

Shifts all values in @self to the left by @amount.

Values smaller than @amount are discarded.

`amount`

amount to shift all values to the left

source#### pub fn shift_right(&self, amount: u32)

#### pub fn shift_right(&self, amount: u32)

Shifts all values in @self to the right by @amount.

Values that end up too large to be held in a #guint are discarded.

`amount`

amount to shift all values to the right

source#### pub fn splice(&self, position: u32, removed: u32, added: u32)

#### pub fn splice(&self, position: u32, removed: u32, added: u32)

This is a support function for `GListModel`

handling, by mirroring
the `GlistModel::items-changed`

signal.

First, it “cuts” the values from @position to @removed from the bitset. That is, it removes all those values and shifts all larger values to the left by @removed places.

Then, it “pastes” new room into the bitset by shifting all values larger than @position by @added spaces to the right. This frees up space that can then be filled.

`position`

position at which to slice

`removed`

number of values to remove

`added`

number of values to add

## Trait Implementations§

source§### impl Ord for Bitset

### impl Ord for Bitset

source§### impl PartialOrd<Bitset> for Bitset

### impl PartialOrd<Bitset> for Bitset

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

#### fn le(&self, other: &Rhs) -> bool

`self`

and `other`

) and is used by the `<=`

operator. Read moresource§### impl StaticType for Bitset

### impl StaticType for Bitset

source§#### fn static_type() -> Type

#### fn static_type() -> Type

`Self`

.