-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitvector.h
50 lines (42 loc) · 1.53 KB
/
bitvector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* $Id: bitvector.h,v 1.5 2001/12/19 22:36:06 acs Exp $
Written by Adam Siepel, Spring 2001
Copyright 2001, Adam Siepel */
/* Routines to construct, query, and perform operations on bit
vectors. Bitwise AND, OR, NOT, and XOR are supported. Functions
have been tuned somewhat for performance. */
#ifndef BITVECTOR_H
#define BITVECTOR_H
#include <stdlib.h>
#include <stdio.h>
#include "priority_stack.h"
#define BYTESIZE 8
enum
{
SZ = sizeof ( char ) * BYTESIZE,
MAXVAL = ( 1 << SZ ) - 1
};
typedef struct bitvector BitVector;
struct bitvector
{
int length;
int nbytes;
char *v;
int capacity;
};
void init_bitvector ( BitVector * bv, int capacity );
void free_bitvector ( BitVector * bv );
void copy_bitvector ( BitVector * dest, BitVector * src );
void bitwise_and ( BitVector * op1, BitVector * op2, BitVector * result );
void bitwise_or ( BitVector * op1, BitVector * op2, BitVector * result );
void bitwise_not ( BitVector * op, BitVector * result );
void bitwise_xor ( BitVector * op1, BitVector * op2, BitVector * result );
void print_bits ( FILE * f, BitVector * v );
void bitvector_set ( BitVector * bv, int pos, int val );
void bitvector_set_func ( BitVector * bv, int func ( void *, int ),
void *data );
int bitvector_get ( BitVector * bv, int pos );
void set_bitvector_length ( BitVector * bv, int len );
void bitvector_clear ( BitVector * bv );
void bitvector_get_positions_of_ones ( BitVector * bv, List * l );
void bitvector_set_positions_of_ones ( BitVector * bv, List * l );
#endif