gtkmm 4.17.0
|
Sets of integers. More...
#include <gtkmm/bitset.h>
Public Types | |
using | const_iterator = BitsetConstIter |
Public Member Functions | |
void | reference () const |
Increment the reference count for this object. | |
void | unreference () const |
Decrement the reference count for this object. | |
GtkBitset * | gobj () |
Provides access to the underlying C instance. | |
const GtkBitset * | gobj () const |
Provides access to the underlying C instance. | |
GtkBitset * | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Bitset ()=delete | |
Bitset (const Bitset &)=delete | |
Bitset & | operator= (const Bitset &)=delete |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
bool | contains (guint value) const |
Checks if the given value has been added to self. | |
bool | is_empty () const |
Check if no value is contained in bitset. | |
guint64 | get_size () const |
Gets the number of values that were added to the set. | |
guint64 | get_size (guint first, guint last) const |
Gets the number of values that are part of the set from first to last (inclusive). | |
guint | get_nth (guint nth) const |
Returns the value of the nth item in self. | |
bool | equals (const Glib::RefPtr< const Bitset > &other) const |
Returns true if self and other contain the same values. | |
guint | get_minimum () const |
Returns the smallest value in self. | |
guint | get_maximum () const |
Returns the largest value in self. | |
Glib::RefPtr< Bitset > | copy () const |
Creates a copy of self. | |
void | remove_all () |
Removes all values from the bitset so that it is empty again. | |
bool | add (guint value) |
Adds value to self if it wasn't part of it before. | |
bool | remove (guint value) |
Removes value from self if it was part of it before. | |
void | add_range (guint start, guint n_items) |
Adds all values from start (inclusive) to start + n_items (exclusive) in self. | |
void | remove_range (guint start, guint n_items) |
Removes all values from start (inclusive) to start + n_items (exclusive) in self. | |
void | add_range_closed (guint first, guint last) |
Adds the closed range [ first, last], so first, last and all values in between. | |
void | remove_range_closed (guint first, guint last) |
Removes the closed range [ first, last], so first, last and all values in between. | |
void | add_rectangle (guint start, guint width, guint height, guint 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. | |
void | remove_rectangle (guint start, guint width, guint height, guint 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. | |
void | join (const Glib::RefPtr< const Bitset > &other) |
Sets self to be the union of self and other. | |
void | intersect (const Glib::RefPtr< const Bitset > &other) |
Sets self to be the intersection of self and other. | |
void | subtract (const Glib::RefPtr< const Bitset > &other) |
Sets self to be the subtraction of other from self. | |
void | difference (const Glib::RefPtr< const Bitset > &other) |
Sets self to be the symmetric difference of self and other. | |
void | shift_left (guint amount) |
Shifts all values in self to the left by amount. | |
void | shift_right (guint amount) |
Shifts all values in self to the right by amount. | |
void | splice (guint position, guint removed, guint value) |
This is a support function for Gio::ListModel handling, by mirroring the GlistModel::items-changed signal. | |
Static Public Member Functions | |
static Glib::RefPtr< Bitset > | create () |
Creates a new empty bitset. | |
Protected Member Functions | |
void | operator delete (void *, std::size_t) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::Bitset > | wrap (GtkBitset *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Sets of integers.
Gtk::Bitset is a data structure for representing a set of unsigned integers. Another name for this data structure is "bitmap".
This version 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. Gtk::Bitset 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 Gtk::BitsetConstIter which allows quick iteration of all the values in a bitset.
The main use case for Gtk::Bitset is implementing complex selections for Gtk::SelectionModel.
|
delete |
bool Gtk::Bitset::add | ( | guint | value | ) |
Adds value to self if it wasn't part of it before.
value | Value to add. |
true
if value was not part of self and self was changed. void Gtk::Bitset::add_range | ( | guint | start, |
guint | n_items | ||
) |
Adds all values from start (inclusive) to start + n_items (exclusive) in self.
start | First value to add. |
n_items | Number of consecutive values to add. |
void Gtk::Bitset::add_range_closed | ( | guint | first, |
guint | last | ||
) |
Adds the closed range [ first, last], so first, last and all values in between.
first must be smaller than last.
first | First value to add. |
last | Last value to add. |
void Gtk::Bitset::add_rectangle | ( | guint | start, |
guint | width, | ||
guint | height, | ||
guint | 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.
start | First value to add. |
width | Width of the rectangle. |
height | Height of the rectangle. |
stride | Row stride of the grid. |
const_iterator Gtk::Bitset::begin | ( | ) | const |
|
inline |
|
inline |
bool Gtk::Bitset::contains | ( | guint | value | ) | const |
Checks if the given value has been added to self.
value | The value to check. |
true
if self contains value. Glib::RefPtr< Bitset > Gtk::Bitset::copy | ( | ) | const |
Creates a copy of self.
|
static |
Creates a new empty bitset.
void Gtk::Bitset::difference | ( | const Glib::RefPtr< const Bitset > & | 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.
other | The Gtk::Bitset to compute the difference from. |
const_iterator Gtk::Bitset::end | ( | ) | const |
bool Gtk::Bitset::equals | ( | const Glib::RefPtr< const Bitset > & | other | ) | const |
Returns true
if self and other contain the same values.
other | Another Gtk::Bitset . |
true
if self and other contain the same values. guint Gtk::Bitset::get_maximum | ( | ) | const |
Returns the largest value in self.
If self is empty, 0 is returned.
guint Gtk::Bitset::get_minimum | ( | ) | const |
Returns the smallest value in self.
If self is empty, G_MAXUINT
is returned.
guint Gtk::Bitset::get_nth | ( | guint | nth | ) | const |
Returns the value of the nth item in self.
If nth is >= the size of self, 0 is returned.
nth | Index of the item to get. |
guint64 Gtk::Bitset::get_size | ( | ) | const |
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 Gio::ListModel
), be sure to use a 64bit type.
guint64 Gtk::Bitset::get_size | ( | guint | first, |
guint | last | ||
) | const |
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 Gio::ListModel
), be sure to use a 64bit type.
first | The first element to include. |
last | The last element to include. |
GtkBitset * Gtk::Bitset::gobj | ( | ) |
Provides access to the underlying C instance.
const GtkBitset * Gtk::Bitset::gobj | ( | ) | const |
Provides access to the underlying C instance.
GtkBitset * Gtk::Bitset::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void Gtk::Bitset::intersect | ( | const Glib::RefPtr< const Bitset > & | 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.
other | The Gtk::Bitset to intersect with. |
bool Gtk::Bitset::is_empty | ( | ) | const |
Check if no value is contained in bitset.
true
if self is empty. void Gtk::Bitset::join | ( | const Glib::RefPtr< const Bitset > & | 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.
other | The Gtk::Bitset to union with. |
void Gtk::Bitset::reference | ( | ) | const |
Increment the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
bool Gtk::Bitset::remove | ( | guint | value | ) |
Removes value from self if it was part of it before.
value | Value to remove. |
true
if value was part of self and self was changed. void Gtk::Bitset::remove_all | ( | ) |
Removes all values from the bitset so that it is empty again.
void Gtk::Bitset::remove_range | ( | guint | start, |
guint | n_items | ||
) |
Removes all values from start (inclusive) to start + n_items (exclusive) in self.
start | First value to remove. |
n_items | Number of consecutive values to remove. |
void Gtk::Bitset::remove_range_closed | ( | guint | first, |
guint | last | ||
) |
Removes the closed range [ first, last], so first, last and all values in between.
first must be smaller than last.
first | First value to remove. |
last | Last value to remove. |
void Gtk::Bitset::remove_rectangle | ( | guint | start, |
guint | width, | ||
guint | height, | ||
guint | 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.
start | First value to remove. |
width | Width of the rectangle. |
height | Height of the rectangle. |
stride | Row stride of the grid. |
void Gtk::Bitset::shift_left | ( | guint | amount | ) |
Shifts all values in self to the left by amount.
Values smaller than amount are discarded.
amount | Amount to shift all values to the left. |
void Gtk::Bitset::shift_right | ( | guint | amount | ) |
Shifts all values in self to the right by amount.
Values that end up too large to be held in a unsigned int
are discarded.
amount | Amount to shift all values to the right. |
void Gtk::Bitset::splice | ( | guint | position, |
guint | removed, | ||
guint | value | ||
) |
This is a support function for Gio::ListModel
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 value spaces to the right. This frees up space that can then be filled.
position | Position at which to slice. |
removed | Number of values to remove. |
value | Number of values to add. |
void Gtk::Bitset::subtract | ( | const Glib::RefPtr< const Bitset > & | 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.
other | The Gtk::Bitset to subtract. |
void Gtk::Bitset::unreference | ( | ) | const |
Decrement the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |