From 279a7d4091950e26057fe36a6dcb4463c2bebb30 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 31 Mar 2001 11:38:21 +0000 Subject: Added e_bit_array_cross_and and e_bit_array_cross_or. 2001-03-31 Christopher James Lahey * gal/util/e-bit-array.c, gal/util/e-bit-array.h: Added e_bit_array_cross_and and e_bit_array_cross_or. svn path=/trunk/; revision=9069 --- e-util/e-bit-array.c | 26 ++++++++++++++++++++++++++ e-util/e-bit-array.h | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/e-util/e-bit-array.c b/e-util/e-bit-array.c index ba65c53120..f8934f8b4e 100644 --- a/e-util/e-bit-array.c +++ b/e-util/e-bit-array.c @@ -294,6 +294,32 @@ e_bit_array_bit_count (EBitArray *eba) return eba->bit_count; } +gboolean +e_bit_array_cross_and (EBitArray *eba) +{ + int i; + for (i = 0; i < eba->bit_count / 32; i++) { + if (eba->data[i] != ONES) + return FALSE; + } + if ((eba->bit_count % 32) && ((eba->data[i] & BITMASK_LEFT(eba->bit_count)) != BITMASK_LEFT(eba->bit_count))) + return FALSE; + return TRUE; +} + +gboolean +e_bit_array_cross_or (EBitArray *eba) +{ + int i; + for (i = 0; i < eba->bit_count / 32; i++) { + if (eba->data[i] != 0) + return TRUE; + } + if ((eba->bit_count % 32) && ((eba->data[i] & BITMASK_LEFT(eba->bit_count)) != 0)) + return TRUE; + return FALSE; +} + #define OPERATE(object, i,mask,grow) ((grow) ? (((object)->data[(i)]) |= ((guint32) ~(mask))) : (((object)->data[(i)]) &= (mask))) void diff --git a/e-util/e-bit-array.h b/e-util/e-bit-array.h index 5cb33b22b7..7469413be3 100644 --- a/e-util/e-bit-array.h +++ b/e-util/e-bit-array.h @@ -57,7 +57,6 @@ void e_bit_array_select_single_row (EBitArray *eba, void e_bit_array_toggle_single_row (EBitArray *eba, int row); -/* Protected Functions */ void e_bit_array_insert (EBitArray *esm, int row, int count); @@ -72,6 +71,9 @@ void e_bit_array_move_row (EBitArray *esm, int new_row); gint e_bit_array_bit_count (EBitArray *esm); +gboolean e_bit_array_cross_and (EBitArray *esm); +gboolean e_bit_array_cross_or (EBitArray *esm); + #ifdef __cplusplus } #endif /* __cplusplus */ -- cgit