49 #ifndef _util_container_bitarray_h
50 #define _util_container_bitarray_h
56 #include <util/misc/formio.h>
71 std::vector<unsigned char> a;
77 ij_offset(
int i,
int j)
79 return (i>j) ? (((i*(i+1)) >> 1) + j) : (((j*(j+1)) >> 1) + i);
86 void set(
unsigned int i) { a[(i>>3)] |= (1 << (i&7)); }
87 void set(
unsigned int i,
unsigned int j) { set(ij_offset(i,j)); }
89 int is_set(
unsigned int i,
unsigned int j)
const
90 {
int ij = ij_offset(i,j);
return (a[(ij>>3)] & (1 << (ij&7))); }
91 int is_set(
unsigned int i)
const
92 {
return (a[(i>>3)] & (1 << (i&7))); }
94 int operator()(
unsigned int i,
unsigned int j)
const
95 {
int ij = ij_offset(i,j);
return (a[(ij>>3)] & (1 << (ij&7))); }
96 int operator()(
unsigned int i)
const
97 {
return (a[(i>>3)] & (1 << (i&7))); }
98 int operator[](
unsigned int i)
const
99 {
return (a[(i>>3)] & (1 << (i&7))); }
101 int dim()
const {
return na; }
102 int nrow()
const {
return nm; }
103 int ncol()
const {
return nm; }
105 int degree(
unsigned int i)
const {
107 for (
int j=0; j < nm; j++)
if ((*
this)(i,j)) nedge++;