Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GtkBitset

[20:7] extends: object

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].

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GtkBitset (Handle = null)

    Creates a new empty bitset.

    • @p Handle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • add (int value)

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

    • @p value is value to add.
    • @r %TRUE if @value was not part of @self and @self was changed.
  • add_range (int start, int n_items)

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

    • @p start is first value to add.
    • @p n_items is number of consecutive values to add.
    • @r None.
  • add_range_closed (int first, int last)

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

    • @p first is first value to add.
    • @p last is last value to add.
    • @r None.
  • add_rectangle (int start, int width, int height, int 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. ``
    • @p start is first value to add.
    • @p width is width of the rectangle.
    • @p height is height of the rectangle.
    • @p stride is row stride of the grid.
    • @r None.
  • contains (int value)

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

    • @p value is the value to check.
    • @r %TRUE if @self contains @value.
  • copy ()

    Creates a copy of @self.

    • @r A new bitset that contains the same values as @self.
  • difference (object other)

    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.

    • @p other is the GtkBitset to compute the difference from.
    • @r None.
  • equals (object other)

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

    • @p other is another GtkBitset.
    • @r %TRUE if @self and @other contain the same values.
  • get_maximum ()

    Returns the largest value in @self. If @self is empty, 0 is returned.

    • @r The largest value in @self.
  • get_minimum ()

    Returns the smallest value in @self. If @self is empty, G_MAXUINT is returned.

    • @r The smallest value in @self.
  • get_nth (int nth)

    Returns the value of the @nth item in self. If @nth is >= the size of

    • @self, 0 is returned.
    • @p nth is index of the item to get.
    • @r the value of the @nth item in @self.
  • get_size ()

    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.

    • @r The number of values in the set..
  • get_size_in_range (int first, int last)

    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.

    • @p first is the first element to include.
    • @p last is the last element to include.
    • @r The number of values in the set from @first to @last..
  • intersect (object other)

    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.

    • @p other is the GtkBitset to intersect with.
    • @r None.
  • is_empty ()

    Check if no value is contained in bitset.

    • @r %TRUE if @self is empty.
  • ref ()

    Acquires a reference on the given GtkBitset.

    • @r the GtkBitset with an additional reference.
  • remove (int value)

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

    • @p value is value to remove.
    • @r %TRUE if @value was part of @self and @self was changed.
  • remove_all ()

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

    • @r None.
  • remove_range (int start, int n_items)

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

    • @p start is first value to remove.
    • @p n_items is number of consecutive values to remove.
    • @r None.
  • remove_range_closed (int first, int last)

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

    • @p first is first value to remove.
    • @p last is last value to remove.
    • @r None.
  • remove_rectangle (int start, int width, int height, int 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.
    • @p start is first value to remove.
    • @p width is width of the rectangle.
    • @p height is height of the rectangle.
    • @p stride is row stride of the grid.
    • @r None.
  • shift_left (int amount)

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

    • @amount are discarded.
    • @p amount is amount to shift all values to the left.
    • @r None.
  • shift_right (int amount)

    Shifts all values in @self to the right by @amount. Values that end up too large to be held in a #guint are discarded.

    • @p amount is amount to shift all values to the right.
    • @r None.
  • splice (int position, int removed, int added)

    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.
    • @p position is position at which to slice.
    • @p removed is number of values to remove.
    • @p added is number of values to add.
    • @r None.
  • subtract (object other)

    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.
    • @p other is the GtkBitset to subtract.
    • @r None.
  • union (object other)

    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.

    • @p other is the GtkBitset to union with.
    • @r None.
  • unref ()

    Releases a reference on the given GtkBitset. If the reference was the last, the resources associated to the @self are freed.

    • @r None.

class: GtkBitsetCtors

[430:14] static extends: object

Alternate constructors for GtkBitset. Usage: GtkBitsetCtors.<name>(...). The primary constructor lives directly on GtkBitset.

Methods

  • newRange (int start, int n_items)

    Creates a bitset with the given range set.

    • @p start is first value to add.
    • @p n_items is number of consecutive values to add.
    • @r A new GtkBitset.