Lucene++ - a full-featured, c++ search engine
API Documentation

Loading...
Searching...
No Matches
BitUtil.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3// Distributable under the terms of either the Apache License (Version 2.0)
4// or the GNU Lesser General Public License.
6
7#ifndef BITUTIL_H
8#define BITUTIL_H
9
10#include "LuceneObject.h"
11
12 namespace Lucene {
13
15 class LPPAPI BitUtil : public LuceneObject {
16 public:
17 virtual ~BitUtil();
18 LUCENE_CLASS(BitUtil);
19
20 public:
22 static const uint8_t ntzTable[];
23
24 public:
26 static int32_t pop(int64_t x);
27
29 static int64_t pop_array(const int64_t* A, int32_t wordOffset, int32_t numWords);
30
32 static int64_t pop_intersect(const int64_t* A, const int64_t* B, int32_t wordOffset, int32_t numWords);
33
35 static int64_t pop_union(const int64_t* A, const int64_t* B, int32_t wordOffset, int32_t numWords);
36
38 static int64_t pop_andnot(const int64_t* A, const int64_t* B, int32_t wordOffset, int32_t numWords);
39
41 static int64_t pop_xor(const int64_t* A, const int64_t* B, int32_t wordOffset, int32_t numWords);
42
44 static int32_t ntz(int64_t val);
45
47 static int32_t ntz(int32_t val);
48
51 static int32_t ntz2(int64_t x);
52
55 static int32_t ntz3(int64_t x);
56
58 static bool isPowerOfTwo(int32_t v);
59
61 static bool isPowerOfTwo(int64_t v);
62
64 static int32_t nextHighestPowerOfTwo(int32_t v);
65
67 static int64_t nextHighestPowerOfTwo(int64_t v);
68
69 protected:
70 inline static void CSA(int64_t& h, int64_t& l, int64_t a, int64_t b, int64_t c);
71};
72
73}
74
75#endif
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::BitUtil
A variety of high efficiency bit twiddling routines.
Definition BitUtil.h:15
Lucene::BitUtil::ntz2
static int32_t ntz2(int64_t x)
Returns 0 based index of first set bit (only works for x!=0) This is an alternate implementation of n...
Lucene::BitUtil::nextHighestPowerOfTwo
static int64_t nextHighestPowerOfTwo(int64_t v)
Returns the next highest power of two, or the current value if it's already a power of two or zero.
Lucene::BitUtil::isPowerOfTwo
static bool isPowerOfTwo(int32_t v)
Returns true if v is a power of two or zero.
Lucene::BitUtil::pop_union
static int64_t pop_union(const int64_t *A, const int64_t *B, int32_t wordOffset, int32_t numWords)
Returns the popcount or cardinality of the union of two sets. Neither array is modified.
Lucene::BitUtil::ntz
static int32_t ntz(int64_t val)
Returns number of trailing zeros in a 64 bit long value.
Lucene::BitUtil::nextHighestPowerOfTwo
static int32_t nextHighestPowerOfTwo(int32_t v)
Returns the next highest power of two, or the current value if it's already a power of two or zero.
Lucene::BitUtil::pop_xor
static int64_t pop_xor(const int64_t *A, const int64_t *B, int32_t wordOffset, int32_t numWords)
Returns the popcount or cardinality of A ^ B. Neither array is modified.
Lucene::BitUtil::pop_intersect
static int64_t pop_intersect(const int64_t *A, const int64_t *B, int32_t wordOffset, int32_t numWords)
Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified.
Lucene::BitUtil::~BitUtil
virtual ~BitUtil()
Lucene::BitUtil::isPowerOfTwo
static bool isPowerOfTwo(int64_t v)
Returns true if v is a power of two or zero.
Lucene::BitUtil::ntz
static int32_t ntz(int32_t val)
Returns number of trailing zeros in a 32 bit int value.
Lucene::BitUtil::pop
static int32_t pop(int64_t x)
Returns the number of bits set in the long.
Lucene::BitUtil::pop_array
static int64_t pop_array(const int64_t *A, int32_t wordOffset, int32_t numWords)
Returns the number of set bits in an array of longs.
Lucene::BitUtil::ntz3
static int32_t ntz3(int64_t x)
Returns 0 based index of first set bit. This is an alternate implementation of ntz().
Lucene::BitUtil::pop_andnot
static int64_t pop_andnot(const int64_t *A, const int64_t *B, int32_t wordOffset, int32_t numWords)
Returns the popcount or cardinality of A & ~B. Neither array is modified.
Lucene::BitUtil::ntzTable
static const uint8_t ntzTable[]
Table of number of trailing zeros in a byte.
Definition BitUtil.h:22
Lucene::BitUtil::CSA
static void CSA(int64_t &h, int64_t &l, int64_t a, int64_t b, int64_t c)
Lucene::LuceneObject::LuceneObject
LuceneObject()
Lucene
Definition AbstractAllTermDocs.h:12

clucene.sourceforge.net