BitsetProtocol
public protocol BitsetProtocol
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 [structGtk.BitsetIter].
The main use case for GtkBitset is implementing complex selections for
[ifaceGtk.SelectionModel].
The BitsetProtocol protocol exposes the methods and properties of an underlying GtkBitset instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Bitset.
Alternatively, use BitsetRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkBitsetinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
bitset_ptrDefault implementationTyped pointer to the underlying
GtkBitsetinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkBitsetinstance.Declaration
Swift
var bitset_ptr: UnsafeMutablePointer<GtkBitset>! { get } -
Required Initialiser for types conforming to
BitsetProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
add(value:Extension method) Adds
valuetoselfif it wasn’t part of it before.Declaration
Swift
@inlinable func add(value: Int) -> Bool -
addRange(start:Extension methodnItems: ) Adds all values from
start(inclusive) tostart+n_items(exclusive) inself.Declaration
Swift
@inlinable func addRange(start: Int, nItems: Int) -
addRangeClosed(first:Extension methodlast: ) Adds the closed range [
first,last], sofirst,lastand all values in between.firstmust be smaller thanlast.Declaration
Swift
@inlinable func addRangeClosed(first: Int, last: Int) -
addRectangle(start:Extension methodwidth: height: stride: ) Interprets the values as a 2-dimensional boolean grid with the given
strideand inside that grid, adds a rectangle with the givenwidthandheight.Declaration
Swift
@inlinable func addRectangle(start: Int, width: Int, height: Int, stride: Int) -
contains(value:Extension method) Checks if the given
valuehas been added toselfDeclaration
Swift
@inlinable func contains(value: Int) -> Bool -
copy()Extension methodCreates a copy of
self.Declaration
Swift
@inlinable func copy() -> BitsetRef! -
difference(other:Extension method) Sets
selfto be the symmetric difference ofselfandother.The symmetric difference is set
selfto contain all values that were either contained inselfor inother, but not in both. This operation is also called an XOR.It is allowed for
selfandotherto be the same bitset. The bitset will be emptied in that case.Declaration
Swift
@inlinable func difference<BitsetT>(other: BitsetT) where BitsetT : BitsetProtocol -
equals(other:Extension method) Returns
trueifselfandothercontain the same values.Declaration
Swift
@inlinable func equals<BitsetT>(other: BitsetT) -> Bool where BitsetT : BitsetProtocol -
getMaximum()Extension methodReturns the largest value in
self.If
selfis empty, 0 is returned.Declaration
Swift
@inlinable func getMaximum() -> Int -
getMinimum()Extension methodReturns the smallest value in
self.If
selfis empty,G_MAXUINTis returned.Declaration
Swift
@inlinable func getMinimum() -> Int -
get(nth:Extension method) Returns the value of the
nthitem in self.If
nthis >= the size ofself, 0 is returned.Declaration
Swift
@inlinable func get(nth: Int) -> Int -
getSize()Extension methodGets 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 isG_MAXUINT + 1. Unless you are sure this cannot happen (it can’t withGListModel), be sure to use a 64bit type.Declaration
Swift
@inlinable func getSize() -> guint64 -
getSizeInRange(first:Extension methodlast: ) Gets the number of values that are part of the set from
firsttolast(inclusive).Note that this function returns a
guint64, because when all values are set, the return value isG_MAXUINT + 1. Unless you are sure this cannot happen (it can’t withGListModel), be sure to use a 64bit type.Declaration
Swift
@inlinable func getSizeInRange(first: Int, last: Int) -> guint64 -
intersect(other:Extension method) Sets
selfto be the intersection ofselfandother.In other words, remove all values from
selfthat are not part ofother.It is allowed for
selfandotherto be the same bitset. Nothing will happen in that case.Declaration
Swift
@inlinable func intersect<BitsetT>(other: BitsetT) where BitsetT : BitsetProtocol -
ref()Extension methodAcquires a reference on the given
GtkBitset.Declaration
Swift
@discardableResult @inlinable func ref() -> BitsetRef! -
remove(value:Extension method) Removes
valuefromselfif it was part of it before.Declaration
Swift
@inlinable func remove(value: Int) -> Bool -
removeAll()Extension methodRemoves all values from the bitset so that it is empty again.
Declaration
Swift
@inlinable func removeAll() -
removeRange(start:Extension methodnItems: ) Removes all values from
start(inclusive) tostart+n_items(exclusive) inself.Declaration
Swift
@inlinable func removeRange(start: Int, nItems: Int) -
removeRangeClosed(first:Extension methodlast: ) Removes the closed range [
first,last], sofirst,lastand all values in between.firstmust be smaller thanlast.Declaration
Swift
@inlinable func removeRangeClosed(first: Int, last: Int) -
removeRectangle(start:Extension methodwidth: height: stride: ) Interprets the values as a 2-dimensional boolean grid with the given
strideand inside that grid, removes a rectangle with the givenwidthandheight.Declaration
Swift
@inlinable func removeRectangle(start: Int, width: Int, height: Int, stride: Int) -
shiftLeft(amount:Extension method) Shifts all values in
selfto the left byamount.Values smaller than
amountare discarded.Declaration
Swift
@inlinable func shiftLeft(amount: Int) -
shiftRight(amount:Extension method) Shifts all values in
selfto the right byamount.Values that end up too large to be held in a
guintare discarded.Declaration
Swift
@inlinable func shiftRight(amount: Int) -
splice(position:Extension methodremoved: added: ) This is a support function for
GListModelhandling, by mirroring theGlistModelitems-changed`` signal.First, it “cuts” the values from
positiontoremovedfrom the bitset. That is, it removes all those values and shifts all larger values to the left byremovedplaces.Then, it “pastes” new room into the bitset by shifting all values larger than
positionbyaddedspaces to the right. This frees up space that can then be filled.Declaration
Swift
@inlinable func splice(position: Int, removed: Int, added: Int) -
subtract(other:Extension method) Sets
selfto be the subtraction ofotherfromself.In other words, remove all values from
selfthat are part ofother.It is allowed for
selfandotherto be the same bitset. The bitset will be emptied in that case.Declaration
Swift
@inlinable func subtract<BitsetT>(other: BitsetT) where BitsetT : BitsetProtocol -
union(other:Extension method) Sets
selfto be the union ofselfandother.That is, add all values from
otherintoselfthat weren’t part of it.It is allowed for
selfandotherto be the same bitset. Nothing will happen in that case.Declaration
Swift
@inlinable func union<BitsetT>(other: BitsetT) where BitsetT : BitsetProtocol -
unref()Extension methodReleases a reference on the given
GtkBitset.If the reference was the last, the resources associated to the
selfare freed.Declaration
Swift
@inlinable func unref() -
bitsetIterInitAt(iter:Extension methodtarget: value: ) Initializes
iterto point totarget.If
targetis not found, finds the next value after it. If no value >=targetexists inset, this function returnsfalse.Declaration
Swift
@inlinable func bitsetIterInitAt<BitsetIterT>(iter: BitsetIterT, target: Int, value: UnsafeMutablePointer<guint>! = nil) -> Bool where BitsetIterT : BitsetIterProtocol -
bitsetIterInitFirst(iter:Extension methodvalue: ) Initializes an iterator for
setand points it to the first value inset.If
setis empty,falseis returned andvalueis set toG_MAXUINT.Declaration
Swift
@inlinable func bitsetIterInitFirst<BitsetIterT>(iter: BitsetIterT, value: UnsafeMutablePointer<guint>! = nil) -> Bool where BitsetIterT : BitsetIterProtocol -
bitsetIterInitLast(iter:Extension methodvalue: ) Initializes an iterator for
setand points it to the last value inset.If
setis empty,falseis returned.Declaration
Swift
@inlinable func bitsetIterInitLast<BitsetIterT>(iter: BitsetIterT, value: UnsafeMutablePointer<guint>! = nil) -> Bool where BitsetIterT : BitsetIterProtocol -
isEmptyExtension methodCheck if no value is contained in bitset.
Declaration
Swift
@inlinable var isEmpty: Bool { get } -
maximumExtension methodReturns the largest value in
self.If
selfis empty, 0 is returned.Declaration
Swift
@inlinable var maximum: Int { get } -
minimumExtension methodReturns the smallest value in
self.If
selfis empty,G_MAXUINTis returned.Declaration
Swift
@inlinable var minimum: Int { get } -
sizeExtension methodGets 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 isG_MAXUINT + 1. Unless you are sure this cannot happen (it can’t withGListModel), be sure to use a 64bit type.Declaration
Swift
@inlinable var size: guint64 { get }
View on GitHub
Install in Dash
BitsetProtocol Protocol Reference