BitSet.xcc
Benoit Dupont de Dinechin (Benoit.Dupont-de-Dinechin@st.com)
Copyright 2007 STMicroelectronics. Copyright 1995 - 1998 Commissariat a l'Energie Atomique.
This program is free software; you can redistribute it and/or modify it under the terms of either (at your option): the GNU General Public License (GPL) version 2; the GNU Lesser General Public License (LGPL) version 2.1; any later version of these licences as published by the Free Software Foundation.
BitSet— Integer Set implemented as a bit vector.
- memory
- The Memory where the BitSet members are stored.
- universe
- This BitSet universe.
struct BitSet_ { //@args Memory memory, int32_t universe IArray_ ARRAY_; //@access ARRAY BitSet__ARRAY_(this) //@access MEMORY IArray_MEMORY(BitSet_ARRAY(this)) //@access WORDS ((BitSetWord *)IArray_BASE(BitSet_ARRAY(this))) };
BitSet_empty— Empty this BitSet
void BitSet_empty(BitSet this);
BitSet_memory— This BitSet memory.
static inline Memory BitSet_memory(const_BitSet this) { return BitSet_MEMORY(this); }
BitSet_wordCount— Count the number of BitSet_WORDs in this BitSet.
static inline int32_t BitSet_wordCount(const_BitSet this) { const_IArray array = BitSet_ARRAY(this); const char *base = IArray_BASE(array); const char *past = IArray_PAST(array); return (past - base)/sizeof(BitSetWord); }
BitSet_words— Return the BitSet word array.
static inline const BitSetWord * BitSet_words(const_BitSet this) { return BitSet_WORDS(this); }
BitSet_isEmpty— True iff this BitSet is empty.
bool BitSet_isEmpty(const_BitSet this);
BitSet_isSingle— True iff this BitSet contains a single member.
#define BitSet_isSingle(this) (BitSet_count(this) == 1)
BitSet_count— Count members contained in the BitSet.
- Return
- The count of members in this BitSet.
int32_t BitSet_count(const_BitSet this);
BitSet_contains— Test a member for containment.
- Return
- True if this BitSet contains member.
static inline bool BitSet_contains(const_BitSet this, BitSetMember member) { BitSetWord old_word, new_word; uint32_t major = BitSet_MAJOR(member); uint32_t minor = BitSet_MINOR(member); Except_REQUIRE(major < BitSet_wordCount(this)); old_word = new_word = BitSet_WORDS(this)[major]; new_word |= ((BitSetWord)1 << minor); return old_word == new_word; }
BitSet_insert— Insert a member in this BitSet.
- Return
- False iff member was already contained in this BitSet.
static inline bool BitSet_insert(BitSet this, BitSetMember member) { BitSetWord old_word, new_word; uint32_t major = BitSet_MAJOR(member); uint32_t minor = BitSet_MINOR(member); Except_REQUIRE(major < BitSet_wordCount(this)); old_word = new_word = BitSet_WORDS(this)[major]; new_word |= ((BitSetWord)1 << minor); BitSet_WORDS(this)[major] = new_word; return old_word != new_word; }
BitSet_remove— Remove a member from this BitSet.
- Return
- False iff member was not contained in this BitSet.
static inline bool BitSet_remove(BitSet this, BitSetMember member) { BitSetWord old_word, new_word; uint32_t major = BitSet_MAJOR(member); uint32_t minor = BitSet_MINOR(member); Except_REQUIRE(major < BitSet_wordCount(this)); old_word = new_word = BitSet_WORDS(this)[major]; new_word &= ~((BitSetWord)1 << minor); BitSet_WORDS(this)[major] = new_word; return old_word != new_word; }
BitSet_choose— Choose and remove a member of the BitSet.
BitSetMember BitSet_choose(BitSet this);
BitSet_nextMember— Get the next member of the BitSet.
BitSetMember BitSet_nextMember(const_BitSet this, BitSetMember member);
BitSet_equals— Test for BitSet equality.
bool BitSet_equals(const_BitSet this, const_BitSet that);
BitSet_union— Union of this BitSet with that BitSet.
bool BitSet_union(BitSet this, BitSet that);
BitSet_inter— Intersect this BitSet with that BitSet.
bool BitSet_inter(BitSet this, BitSet that);
BitSet_diff— Remove that BitSet members from this BitSet.
bool BitSet_diff(BitSet this, BitSet that);
BitSet_FOREACH— Iterates over the BitSet entries.
- this
- This BitSet.
#define BitSet_FOREACH(this, iter) { \ BitSetMember iter = 0; \ int32_t BitSet_COUNT = BitSet_wordCount(this), BitSet_I, BitSet_J; \ for (BitSet_I = 0; BitSet_I < BitSet_COUNT; BitSet_I++) { \ BitSetWord BitSet_WORD = BitSet_words(this)[BitSet_I]; \ for (BitSet_J = 0; BitSet_J < BitSet_WORDBITS; BitSet_J++, BitSet_WORD >>= 1, iter++) { \ if (BitSet_WORD & 1) { #define BitSet_ENDEACH \ } \ } \ if (BitSet_J != BitSet_WORDBITS) break; \ } \ }