File: block.h

package info (click to toggle)
glam2 1064-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 956 kB
  • sloc: ansic: 6,925; xml: 757; asm: 74; makefile: 54; sh: 11
file content (76 lines) | stat: -rw-r--r-- 3,233 bytes parent folder | download | duplicates (4)
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
69
70
71
72
73
74
75
76
#if !defined(BLOCKS)
#define BLOCKS
#include <stdio.h>
#include <math.h>
#include "stdinc.h"

/*************************** ADT Block *******************************

    B = subset of { 0,...,n-1 } where n is an element of Postive integers.

**********************************************************************/
typedef struct {
	unsigned short	*list;		/* list of non-zero words */
	unsigned short	*list2;		/* 2nd list of non-zero words */
	unsigned char		*b;	/* as bytes = 8 bits */
	unsigned long	*i;		/* as long ints = 32 bits */
	long		N;		/* maximum number in set */
	long		nbyte;		/* number of bytes in array */
	long		nint;		/* number of ints in array */
} block_type;

typedef	block_type	*b_type;

/*************************** Private *******************************/
extern unsigned char *CARDINALITY_BLOCKS;
extern unsigned long *SET_BIT_BLOCKS;
extern unsigned short *B1_list,*B2_list,*IB_list;
extern unsigned char *B1_byte,*B2_byte,*IB_byte;

void    initialize_blocks();
void    add_list_block(b_type B);
void    update_list_block(b_type B);
void    blockerror(char *s);
/*************************** Public ********************************/
b_type	Block(long N);			/* create Null block */
b_type	BlockL(long N);			/* create Null block with list */
void    CopyBlock(b_type B1,b_type B2);
void    CopyBlockL(b_type B1,b_type B2);
void    CopyBlockL2(b_type B1, b_type B2);
void    CopyBlockLL(register b_type B1,register b_type B2);
void    ClearBlock(b_type B);			/* zero out a set in B */
void    FillBlock(b_type B);
void	AddBlock(long element,b_type B); 	/* add an element to set B */
void	DeleteBlock(long element,b_type B);
unsigned long    MemberBlock(register long element, register b_type B);
b_type  UnionBlock(b_type B1, b_type B2);
void    UnionBlock3(b_type B1, b_type B2, b_type UB);
long	UnionBlockCL(b_type B1, b_type B2);
void	UnionBlockL(b_type B1, b_type B2);
void    UnionBlockLF(b_type B1, b_type B2, b_type UB);
void    IntersectNotBlock(b_type B1, b_type B2);
void    IntersectBlock3(b_type B1, b_type B2);
void	IntersectBlock1(b_type B1, b_type B2,b_type IB);
long     IntersectBlockCF(b_type B1,b_type B2,b_type IB);
void	IntersectBlockF(b_type B1,b_type B2,b_type IB);
void	IntersectBlockL(b_type B1,b_type B2);
long     IntersectBlockList(long  *L, b_type B1, b_type B2);
long     IntersectBlockLCXOR(b_type eB,b_type B, b_type IB);
long	CardBlock(b_type B);	/* return cardinality of a set in B */
long     CardBlockL(b_type B);
long	CardInterBlock(b_type B1,b_type B2);
long	CardInterBlockLF(b_type B1,b_type B2);
void	CardInterBlockLMult(register long *C, b_type *B1,b_type B2);
long     *ListBlock(b_type B);	/* return list of members in B */
long     *ListBlockL(b_type B);	/* return list of members in B */
b_type	PutBlock(FILE *fptr,b_type B);	/* print block B */
b_type	NilBlock(b_type B);		/* destroy ISets */
/*************************** Macros **********************/
#define MAX_BLOCK_SIZE	524000		/* = list of 65500 */
#define BLOCK_BUFFER_SIZE	65505	/* for temp list */
#define END_BLOCK_LIST	65530
#define BlockN(B)	((B)->N)	/* return max cardinality of sets */
#define EmptyBlockL(B)	((B)->list[0]==END_BLOCK_LIST)
#define ClearBlockL(B)	((B)->list[0]=END_BLOCK_LIST)

#endif