`#[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

source#### fn partial_cmp(&self, other: &Bitset) -> Option<Ordering>

#### fn partial_cmp(&self, other: &Bitset) -> Option<Ordering>

This method returns an ordering between `self`

and `other`

values if one exists. Read more

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

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

This method tests less than (for `self`

and `other`

) and is used by the `<`

operator. Read more

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

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

This method tests less than or equal to (for `self`

and `other`

) and is used by the `<=`

operator. Read more

source### impl StaticType for Bitset

### impl StaticType for Bitset

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

#### fn static_type() -> Type

Returns the type identifier of `Self`

.

### impl Eq for Bitset

### impl StructuralEq for Bitset

### impl StructuralPartialEq for Bitset

## Auto Trait Implementations

### impl RefUnwindSafe for Bitset

### impl !Send for Bitset

### impl !Sync for Bitset

### impl Unpin for Bitset

### impl UnwindSafe for Bitset

## Blanket Implementations

source### impl<T> BorrowMut<T> for T where

T: ?Sized,

### impl<T> BorrowMut<T> for T where

T: ?Sized,

const: unstable · source#### fn borrow_mut(&mut self) -> &mut T

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more

source### impl<T> StaticTypeExt for T where

T: StaticType,

### impl<T> StaticTypeExt for T where

T: StaticType,

source#### fn ensure_type()

#### fn ensure_type()

Ensures that the type has been registered with the type system.