49 #ifndef _util_container_bitarray_h
50 #define _util_container_bitarray_h
55 #include <util/misc/formio.h>
76 ij_offset(
int i,
int j)
78 return (i>j) ? (((i*(i+1)) >> 1) + j) : (((j*(j+1)) >> 1) + i);
85 void set(
unsigned int i) { a[(i>>3)] |= (1 << (i&7)); }
86 void set(
unsigned int i,
unsigned int j) { set(ij_offset(i,j)); }
88 int is_set(
unsigned int i,
unsigned int j)
const
89 {
int ij = ij_offset(i,j);
return (a[(ij>>3)] & (1 << (ij&7))); }
90 int is_set(
unsigned int i)
const
91 {
return (a[(i>>3)] & (1 << (i&7))); }
93 int operator()(
unsigned int i,
unsigned int j)
const
94 {
int ij = ij_offset(i,j);
return (a[(ij>>3)] & (1 << (ij&7))); }
95 int operator()(
unsigned int i)
const
96 {
return (a[(i>>3)] & (1 << (i&7))); }
97 int operator[](
unsigned int i)
const
98 {
return (a[(i>>3)] & (1 << (i&7))); }
100 int dim()
const {
return na; }
101 int nrow()
const {
return nm; }
102 int ncol()
const {
return nm; }
104 int degree(
unsigned int i)
const {
106 for (
int j=0; j < nm; j++)
if ((*
this)(i,j)) nedge++;