Bitset

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 [struct@Gtk.BitsetIter].

The main use case for GtkBitset is implementing complex selections for [iface@Gtk.SelectionModel].

Constructors

this
this(GtkBitset* gtkBitset, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new empty bitset.

this
this(uint start, uint nItems)

Creates a bitset with the given range set.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

doref
alias doref = ref_
Undocumented in source.
unio
alias unio = union_
Undocumented in source.

Functions

add
bool add(uint value)

Adds @value to @self if it wasn't part of it before.

addRange
void addRange(uint start, uint nItems)

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

addRangeClosed
void addRangeClosed(uint first, uint last)

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

addRectangle
void addRectangle(uint start, uint width, uint height, uint stride)

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.

contains
bool contains(uint value)

Checks if the given @value has been added to @self

copy
Bitset copy()

Creates a copy of @self.

difference
void difference(Bitset other)

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

equals
bool equals(Bitset other)

Returns %TRUE if @self and @other contain the same values.

getBitsetStruct
GtkBitset* getBitsetStruct(bool transferOwnership)

Get the main Gtk struct

getMaximum
uint getMaximum()

Returns the largest value in @self.

getMinimum
uint getMinimum()

Returns the smallest value in @self.

getNth
uint getNth(uint nth)

Returns the value of the @nth item in self.

getSize
ulong getSize()

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

getSizeInRange
ulong getSizeInRange(uint first, uint last)

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

getStruct
void* getStruct()

the main Gtk struct as a void*

intersect
void intersect(Bitset other)

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

isEmpty
bool isEmpty()

Check if no value is contained in bitset.

ref_
Bitset ref_()

Acquires a reference on the given GtkBitset.

remove
bool remove(uint value)

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

removeAll
void removeAll()

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

removeRange
void removeRange(uint start, uint nItems)

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

removeRangeClosed
void removeRangeClosed(uint first, uint last)

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

removeRectangle
void removeRectangle(uint start, uint width, uint height, uint stride)

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.

shiftLeft
void shiftLeft(uint amount)

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

shiftRight
void shiftRight(uint amount)

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

splice
void splice(uint position, uint removed, uint added)

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

subtract
void subtract(Bitset other)

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

union_
void union_(Bitset other)

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

unref
void unref()

Releases a reference on the given GtkBitset.

Static functions

getType
GType getType()

Variables

gtkBitset
GtkBitset* gtkBitset;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta