gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Structs.Bitset

Contents

- Exported types
- Methods
  - add
  - addRange
  - addRangeClosed
  - addRectangle
  - contains
  - copy
  - difference
  - equals
  - getMaximum
  - getMinimum
  - getNth
  - getSize
  - getSizeInRange
  - intersect
  - isEmpty
  - newEmpty
  - newRange
  - ref
  - remove
  - removeAll
  - removeRange
  - removeRangeClosed
  - removeRectangle
  - shiftLeft
  - shiftRight
  - splice
  - subtract
  - union
  - unref

Description

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 `BitsetIter`.

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

Synopsis

- newtype Bitset = Bitset (ManagedPtr Bitset)
- bitsetAdd :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m Bool
- bitsetAddRange :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> m ()
- bitsetAddRangeClosed :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> m ()
- bitsetAddRectangle :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> Word32 -> Word32 -> m ()
- bitsetContains :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m Bool
- bitsetCopy :: (HasCallStack, MonadIO m) => Bitset -> m Bitset
- bitsetDifference :: (HasCallStack, MonadIO m) => Bitset -> Bitset -> m ()
- bitsetEquals :: (HasCallStack, MonadIO m) => Bitset -> Bitset -> m Bool
- bitsetGetMaximum :: (HasCallStack, MonadIO m) => Bitset -> m Word32
- bitsetGetMinimum :: (HasCallStack, MonadIO m) => Bitset -> m Word32
- bitsetGetNth :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m Word32
- bitsetGetSize :: (HasCallStack, MonadIO m) => Bitset -> m Word64
- bitsetGetSizeInRange :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> m Word64
- bitsetIntersect :: (HasCallStack, MonadIO m) => Bitset -> Bitset -> m ()
- bitsetIsEmpty :: (HasCallStack, MonadIO m) => Bitset -> m Bool
- bitsetNewEmpty :: (HasCallStack, MonadIO m) => m Bitset
- bitsetNewRange :: (HasCallStack, MonadIO m) => Word32 -> Word32 -> m Bitset
- bitsetRef :: (HasCallStack, MonadIO m) => Bitset -> m Bitset
- bitsetRemove :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m Bool
- bitsetRemoveAll :: (HasCallStack, MonadIO m) => Bitset -> m ()
- bitsetRemoveRange :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> m ()
- bitsetRemoveRangeClosed :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> m ()
- bitsetRemoveRectangle :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> Word32 -> Word32 -> m ()
- bitsetShiftLeft :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m ()
- bitsetShiftRight :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> m ()
- bitsetSplice :: (HasCallStack, MonadIO m) => Bitset -> Word32 -> Word32 -> Word32 -> m ()
- bitsetSubtract :: (HasCallStack, MonadIO m) => Bitset -> Bitset -> m ()
- bitsetUnion :: (HasCallStack, MonadIO m) => Bitset -> Bitset -> m ()
- bitsetUnref :: (HasCallStack, MonadIO m) => Bitset -> m ()

# Exported types

newtype Bitset Source #

Memory-managed wrapper type.

Constructors

Bitset (ManagedPtr Bitset) |

#### Instances

Instances details

Eq Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset Methods (==) :: Bitset -> Bitset -> Bool Source # (/=) :: Bitset -> Bitset -> Bool Source #
GBoxed Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset
ManagedPtrNewtype Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset Methods toManagedPtr :: Bitset -> ManagedPtr Bitset Source #
TypedObject Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset Methods glibType :: IO GType Source #
HasParentTypes Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset
IsGValue (Maybe Bitset) Source # | Convert `Bitset` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Structs.Bitset Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Bitset -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Bitset) Source #
type ParentTypes Bitset Source # |
Instance details Defined in GI.Gtk.Structs.Bitset type ParentTypes Bitset = '[] :: [Type]

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

add, addRange, addRangeClosed, addRectangle, contains, copy, difference, equals, intersect, isEmpty, ref, remove, removeAll, removeRange, removeRangeClosed, removeRectangle, shiftLeft, shiftRight, splice, subtract, union, unref.

#### Getters

getMaximum, getMinimum, getNth, getSize, getSizeInRange.

#### Setters

None.

## add

bitsetAdd Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `value`: value to add
-> m Bool | Returns: `True` if `value` was not part of `self` and `self` was changed

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

## addRange

bitsetAddRange Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `start`: first value to add
-> Word32 | `nItems`: number of consecutive values to add
-> m () |

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

## addRangeClosed

bitsetAddRangeClosed Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `first`: first value to add
-> Word32 | `last`: last value to add
-> m () |

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

## addRectangle

bitsetAddRectangle Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `start`: first value to add
-> Word32 | `width`: width of the rectangle
-> Word32 | `height`: height of the rectangle
-> Word32 | `stride`: row stride of the grid
-> m () |

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

bitsetContains Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `value`: the value to check
-> m Bool | Returns: `True` if `self` contains `value`

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

## copy

bitsetCopy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Bitset | Returns: A new bitset that contains the same values as `self`

Creates a copy of `self`.

## difference

bitsetDifference Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Bitset | `other`: the `GtkBitset` to compute the difference from
-> m () |

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.

## equals

bitsetEquals Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Bitset | `other`: another `GtkBitset`
-> m Bool | Returns: `True` if `self` and `other` contain the same values

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

## getMaximum

bitsetGetMaximum Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Word32 | Returns: The largest value in `self`

Returns the largest value in `self`.

If `self` is empty, 0 is returned.

## getMinimum

bitsetGetMinimum Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Word32 | Returns: The smallest value in `self`

Returns the smallest value in `self`.

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

## getNth

bitsetGetNth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `nth`: index of the item to get
-> m Word32 | Returns: the value of the `nth` item in `self`

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

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

## getSize

bitsetGetSize Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Word64 | Returns: The number of values in the set.

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.

## getSizeInRange

bitsetGetSizeInRange Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `first`: the first element to include
-> Word32 | `last`: the last element to include
-> m Word64 | Returns: The number of values in the set from `first` to `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.

## intersect

bitsetIntersect Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Bitset | `other`: the `GtkBitset` to intersect with
-> m () |

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.

## isEmpty

bitsetIsEmpty Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Bool | Returns: `True` if `self` is empty

Check if no value is contained in bitset.

## newEmpty

bitsetNewEmpty Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Bitset | Returns: A new empty bitset

Creates a new empty bitset.

## newRange

bitsetNewRange Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Word32 | `start`: first value to add
-> Word32 | `nItems`: number of consecutive values to add
-> m Bitset | Returns: A new bitset

Creates a bitset with the given range set.

## ref

bitsetRef Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m Bitset | Returns: the `GtkBitset` with an additional reference

Acquires a reference on the given `GtkBitset`.

## remove

bitsetRemove Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `value`: value to remove
-> m Bool | Returns: `True` if `value` was part of `self` and `self` was changed

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

## removeAll

bitsetRemoveAll Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m () |

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

## removeRange

bitsetRemoveRange Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `start`: first value to remove
-> Word32 | `nItems`: number of consecutive values to remove
-> m () |

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

## removeRangeClosed

bitsetRemoveRangeClosed Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `first`: first value to remove
-> Word32 | `last`: last value to remove
-> m () |

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

## removeRectangle

bitsetRemoveRectangle Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `start`: first value to remove
-> Word32 | `width`: width of the rectangle
-> Word32 | `height`: height of the rectangle
-> Word32 | `stride`: row stride of the grid
-> m () |

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

bitsetShiftLeft Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `amount`: amount to shift all values to the left
-> m () |

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

Values smaller than `amount` are discarded.

## shiftRight

bitsetShiftRight Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `amount`: amount to shift all values to the right
-> m () |

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

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

## splice

bitsetSplice Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Word32 | `position`: position at which to slice
-> Word32 | `removed`: number of values to remove
-> Word32 | `added`: number of values to add
-> m () |

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.

## subtract

bitsetSubtract Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Bitset | `other`: the `GtkBitset` to subtract
-> m () |

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.

## union

bitsetUnion Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> Bitset | `other`: the `GtkBitset` to union with
-> m () |

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.

## unref

bitsetUnref Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bitset | `self`: a `GtkBitset`
-> m () |

Releases a reference on the given `GtkBitset`.

If the reference was the last, the resources associated to the `self` are freed.