/* *mbms_add_member *Addanewmembertoamultibitmapset. * *Thenewmemberisidentifiedby"listidx",thezero-basedindexofthe *Listelementitshouldgointo,and"bitidx",whichspecifiesthebit *numbertobesettherein. * *Thisislikebms_add_member,butformultibitmapsets.
*/
List *
mbms_add_member(List *a, int listidx, int bitidx)
{
Bitmapset *bms;
ListCell *lc;
if (listidx < 0 || bitidx < 0)
elog(ERROR, "negative multibitmapset member index not allowed"); /* Add empty elements as needed */ while (list_length(a) <= listidx)
a = lappend(a, NULL); /* Update the target element */
lc = list_nth_cell(a, listidx);
bms = lfirst_node(Bitmapset, lc);
bms = bms_add_member(bms, bitidx);
lfirst(lc) = bms; return a;
}
/* *mbms_add_members *Addallmembersofsetbtoseta. * *ThisisaUNIONoperation,buttheleftinputismodifiedin-place. * *Thisislikebms_add_members,butformultibitmapsets.
*/
List *
mbms_add_members(List *a, const List *b)
{
ListCell *lca,
*lcb;
/* Add empty elements to a, as needed */ while (list_length(a) < list_length(b))
a = lappend(a, NULL); /* forboth will stop at the end of the shorter list, which is fine */
forboth(lca, a, lcb, b)
{
Bitmapset *bmsa = lfirst_node(Bitmapset, lca); const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
/* *mbms_int_members *Reducesetatoitsintersectionwithsetb. * *ThisisanINTERSECToperation,buttheleftinputismodifiedin-place. * *Thisislikebms_int_members,butformultibitmapsets.
*/
List *
mbms_int_members(List *a, const List *b)
{
ListCell *lca,
*lcb;
/* Remove any elements of a that are no longer of use */
a = list_truncate(a, list_length(b)); /* forboth will stop at the end of the shorter list, which is fine */
forboth(lca, a, lcb, b)
{
Bitmapset *bmsa = lfirst_node(Bitmapset, lca); const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
/* *mbms_is_member *Islistidx/bitidxamemberofA? * *Thisislikebms_is_member,butformultibitmapsets.
*/ bool
mbms_is_member(int listidx, int bitidx, const List *a)
{ const Bitmapset *bms;
/* XXX better to just return false for negative indexes? */ if (listidx < 0 || bitidx < 0)
elog(ERROR, "negative multibitmapset member index not allowed"); if (listidx >= list_length(a)) returnfalse;
bms = list_nth_node(Bitmapset, a, listidx); return bms_is_member(bitidx, bms);
}
/* forboth will stop at the end of the shorter list, which is fine */
forboth(lca, a, lcb, b)
{ const Bitmapset *bmsa = lfirst_node(Bitmapset, lca); const Bitmapset *bmsb = lfirst_node(Bitmapset, lcb);
if (bms_overlap(bmsa, bmsb))
result = bms_add_member(result, foreach_current_index(lca));
} return result;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.