projects
/
SXSI
/
XMLTree.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Backport changes from the grammar branch
[SXSI/XMLTree.git]
/
libcds
/
src
/
basics.h
diff --git
a/libcds/src/basics.h
b/libcds/src/basics.h
index
9c88ad2
..
85bfe22
100644
(file)
--- a/
libcds/src/basics.h
+++ b/
libcds/src/basics.h
@@
-1,5
+1,5
@@
/* basics.h
/* basics.h
- * Copyright (C) 200
8, Rodrigo Gonzalez & Francisco Claude
, all rights reserved.
+ * Copyright (C) 200
5, Rodrigo Gonzalez
, all rights reserved.
*
* Some preliminary stuff
*
*
* Some preliminary stuff
*
@@
-23,8
+23,16
@@
#ifndef _BASICS_H
#define _BASICS_H
#ifndef _BASICS_H
#define _BASICS_H
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/times.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
#include <iostream>
#include <iostream>
-using namespace std;
+#include <iostream>
+////using namespace std;
#include <cstdlib>
#include <cmath>
#include <cstdlib>
#include <cmath>
@@
-33,18
+41,21
@@
using namespace std;
#define mask31 0x0000001F
/** max function */
#define mask31 0x0000001F
/** max function */
-#define max(x,y) ((x)>(y)?(x):(y))
+
//
#define max(x,y) ((x)>(y)?(x):(y))
/** min function */
/** min function */
-#define min(x,y) ((x)<(y)?(x):(y))
+
//
#define min(x,y) ((x)<(y)?(x):(y))
/** number of bits in a uint */
/** number of bits in a uint */
+#undef W
#define W 32
/** W-1 */
#define W 32
/** W-1 */
+#undef Wminusone
#define Wminusone 31
/** 2W*/
#define Wminusone 31
/** 2W*/
+#undef WW
#define WW 64
/** number of bits per uchar */
#define WW 64
/** number of bits per uchar */
@@
-131,7
+142,10
@@
inline uint bits(uint n){
#define bitclean(e,p) ((e)[(p)/W] &= ~(1<<((p)%W)))
/** uints required to represent e integers of n bits each */
#define bitclean(e,p) ((e)[(p)/W] &= ~(1<<((p)%W)))
/** uints required to represent e integers of n bits each */
-#define uint_len(e,n) (((e)*(n))/W+(((e)*(n))%W > 0))
+//#define uint_len(e,n) (((e)*(n))/W+(((e)*(n))%W > 0))
+inline uint uint_len(uint e, uint n) {
+ return ((unsigned long long)e*n/W+((unsigned long long)e*n%W>0));
+}
/** Retrieve a given index from array A where every value uses len bits
* @param A Array
/** Retrieve a given index from array A where every value uses len bits
* @param A Array
@@
-219,6
+233,20
@@
inline uint popcount(int x){
return __popcount_tab[(x >> 0) & 0xff] + __popcount_tab[(x >> 8) & 0xff]
+ __popcount_tab[(x >> 16) & 0xff] + __popcount_tab[(x >> 24) & 0xff];
}
return __popcount_tab[(x >> 0) & 0xff] + __popcount_tab[(x >> 8) & 0xff]
+ __popcount_tab[(x >> 16) & 0xff] + __popcount_tab[(x >> 24) & 0xff];
}
+inline unsigned int
+fast_popcount(int x)
+{
+ uint m1 = 0x55555555;
+ uint m2 = 0x33333333;
+ uint m4 = 0x0f0f0f0f;
+ x -= (x >> 1) & m1;
+ x = (x & m2) + ((x >> 2) & m2);
+ x = (x + (x >> 4)) & m4;
+ x += x >> 8;
+ return (x + (x >> 16)) & 0x3f;
+}
+
+
/** Counts the number of 1s in the first 16 bits of x */
inline uint popcount16(int x){
/** Counts the number of 1s in the first 16 bits of x */
inline uint popcount16(int x){