bitset.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 

immutable class BITSET

immutable class BITSET is attr p:INT; create:SAME is res:SAME; return res.p(0); end; create(n:INT):SAME is res:SAME; return res.p(n); end; clone:SAME is return self; end; int:INT is return p; end; b(i:INT):SAME is return create(1.lshift(i)); end; is_empty:BOOL is return p=0; end; is_eq(other:SAME):BOOL is return p=other.p; end; negate:SAME is return create(p.bnot); end; not:SAME is return create(p.bnot); end; plus(other:SAME):SAME is return create(p.bor(other.p)); end; nor(other:SAME):SAME is return create(p.bnor(other.p)); end; --or(other:SAME):SAME is return bor(other); end; times(other:SAME):SAME is return create(p.band(other.p)); end; --and(other:SAME):SAME is return band(other); end; nand(other:SAME):SAME is return create(p.bnand(other.p)); end; div(other:SAME):SAME is return create(p.beqv(other.p).bnot); end; xor(other:SAME):SAME is return create(p.bxor(other.p)); end; nxor(other:SAME):SAME is return create(p.beqv(other.p)); end; minus(other:SAME):SAME is return create(p.band(other.p.bnot)); end; is_subset(other:SAME):BOOL is return p.band(other.p.bnot).is_eq(0); end; in(other:SAME):BOOL is return p.band(other.p.bnot).is_eq(0); end; meet(o:SAME):BOOL is return (p.band(o.p)/=0); end; end;