forked from PolMine/RcppCWB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitfields.h
More file actions
68 lines (47 loc) · 1.85 KB
/
Copy pathbitfields.h
File metadata and controls
68 lines (47 loc) · 1.85 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* IMS Open Corpus Workbench (CWB)
* Copyright (C) 1993-2006 by IMS, University of Stuttgart
* Copyright (C) 2007- by the respective contributers (see file AUTHORS)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details (in the file "COPYING", or available via
* WWW at http://www.gnu.org/copyleft/gpl.html).
*/
#ifndef _bitfields_h
#define _bitfields_h
#include "globals.h"
#include <limits.h>
typedef unsigned char BFBaseType;
/**
* Underlying storage of Bitfield object.
*/
typedef struct BFBuf {
int elements; /**< The number of bits in the bitfield */
int bytes; /**< The number of bytes the bitfield occupies */
int nr_bits_set; /**< The number of bits whose value has been assigned. Initialised to 0. */
BFBaseType *field; /**< the bitfield data itself. All elements initialised to 0. */
} BFBuf;
/**
* The Bitfield object.
*/
typedef struct BFBuf *Bitfield;
Bitfield create_bitfield(int nr_of_elements);
Bitfield copy_bitfield(Bitfield source);
void destroy_bitfield(Bitfield *bptr);
int set_bit(Bitfield bitfield, int element);
int clear_bit(Bitfield bitfield, int element);
int clear_all_bits(Bitfield bitfield);
int set_all_bits(Bitfield bitfield);
int get_bit(Bitfield bitfield, int element);
int toggle_bit(Bitfield bitfield, int element);
int nr_bits_set(Bitfield bitfield);
int bf_equal(Bitfield bf1, Bitfield bf2);
int bf_compare(Bitfield bf1, Bitfield bf2);
#endif