package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Bitset

type t = [ `bitset ] Gobject.obj

A `GtkBitset` represents a set of unsigned integers.

Another name for this data structure is "bitmap".

The current implementation is based on roaring bitmaps(https://roaringbitmap.org/).

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.

val new_empty : unit -> t

Create a new Bitset

val new_range : int -> int -> t

Create a new Bitset

val union : t -> t -> unit

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

That is, add all values from @other into @self that weren't part of it.

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

val subtract : t -> t -> unit

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

In other words, remove all values from @self that are part of @other.

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

val splice : t -> int -> int -> int -> unit

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.

val shift_right : t -> int -> unit

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

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

val shift_left : t -> int -> unit

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

Values smaller than @amount are discarded.

val remove_rectangle : t -> int -> int -> int -> int -> unit

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.

val remove_range_closed : t -> int -> int -> unit

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

val remove_range : t -> int -> int -> unit

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

val remove_all : t -> unit

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

val remove : t -> int -> bool

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

val ref : t -> t

Acquires a reference on the given `GtkBitset`.

val is_empty : t -> bool

Check if no value is contained in bitset.

val intersect : t -> t -> unit

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

In other words, remove all values from @self that are not part of @other.

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

val get_size_in_range : t -> int -> int -> UInt64.t

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.

val get_size : t -> UInt64.t

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.

val get_nth : t -> int -> int

Returns the value of the @nth item in self.

If @nth is >= the size of @self, 0 is returned.

val get_minimum : t -> int

Returns the smallest value in @self.

If @self is empty, `G_MAXUINT` is returned.

val get_maximum : t -> int

Returns the largest value in @self.

If @self is empty, 0 is returned.

val equals : t -> t -> bool

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

val difference : t -> t -> unit

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.

val contains : t -> int -> bool

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

val add_rectangle : t -> int -> int -> int -> int -> unit

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.

val add_range_closed : t -> int -> int -> unit

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

val add_range : t -> int -> int -> unit

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

val add : t -> int -> bool

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

val get_type : unit -> Gobject.Type.t