### Struct

# Gtk Bitset

since: 4.0

#### Description [src]

    struct GtkBitset {
      /* No available fields */
    }

A `GtkBitset` 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. `GtkBitset` 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 `GtkBitsetIter`.

The main use case for `GtkBitset` is implementing complex selections for `GtkSelectionModel`.

Available since: 4.0

#### Constructors

###### gtk_bitset_new_empty

Creates a new empty bitset.

since: 4.0

###### gtk_bitset_new_range

Creates a bitset with the given range set.

since: 4.0

#### Instance methods

###### gtk_bitset_add

Adds `value` to `self` if it wasn’t part of it before.

since: 4.0

###### gtk_bitset_add_range

Adds all values from `start` (inclusive) to `start` + `n_items` (exclusive) in `self`.

since: 4.0

###### gtk_bitset_add_range_closed

Adds the closed range [`first`, `last`], so `first`, `last` and all values in between. `first` must be smaller than `last`.

since: 4.0

###### gtk_bitset_add_rectangle

Interprets the values as a 2-dimensional boolean grid with the given `stride` and inside that grid, adds a rectangle with the given `width` and `height`.

since: 4.0

###### gtk_bitset_contains

Checks if the given `value` has been added to `self`.

since: 4.0

###### gtk_bitset_copy

Creates a copy of `self`.

since: 4.0

###### gtk_bitset_difference

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

since: 4.0

###### gtk_bitset_equals

Returns `TRUE` if `self` and `other` contain the same values.

since: 4.0

###### gtk_bitset_get_maximum

Returns the largest value in `self`.

since: 4.0

###### gtk_bitset_get_minimum

Returns the smallest value in `self`.

since: 4.0

###### gtk_bitset_get_nth

Returns the value of the `nth` item in self.

since: 4.0

###### gtk_bitset_get_size

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

since: 4.0

###### gtk_bitset_get_size_in_range

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

since: 4.0

###### gtk_bitset_intersect

Sets `self` to be the intersection of `self` and `other`.

since: 4.0

###### gtk_bitset_is_empty

Check if no value is contained in bitset.

since: 4.0

###### gtk_bitset_ref

Acquires a reference on the given `GtkBitset`.

since: 4.0

###### gtk_bitset_remove

Removes `value` from `self` if it was part of it before.

since: 4.0

###### gtk_bitset_remove_all

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

since: 4.0

###### gtk_bitset_remove_range

Removes all values from `start` (inclusive) to `start` + `n_items` (exclusive) in `self`.

since: 4.0

###### gtk_bitset_remove_range_closed

Removes the closed range [`first`, `last`], so `first`, `last` and all values in between. `first` must be smaller than `last`.

since: 4.0

###### gtk_bitset_remove_rectangle

Interprets the values as a 2-dimensional boolean grid with the given `stride` and inside that grid, removes a rectangle with the given `width` and `height`.

since: 4.0

###### gtk_bitset_shift_left

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

since: 4.0

###### gtk_bitset_shift_right

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

since: 4.0

###### gtk_bitset_splice

This is a support function for `GListModel` handling, by mirroring the `GlistModel::items-changed` signal.

since: 4.0

###### gtk_bitset_subtract

Sets `self` to be the subtraction of `other` from `self`.

since: 4.0

###### gtk_bitset_union

Sets `self` to be the union of `self` and `other`.

since: 4.0

###### gtk_bitset_unref

Releases a reference on the given `GtkBitset`.

since: 4.0