/** * Copyright 2003-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _lucene_util_BitVector_ #define _lucene_util_BitVector_ #if defined(_LUCENE_PRAGMA_ONCE) # pragma once #endif #include "CLucene/store/Directory.h" CL_NS_DEF(util) /** Optimized implementation of a vector of bits. This is more-or-less like java.util.BitSet, but also includes the following:
n
bits.
BitVector(int32_t n);
/// Destructor for the BitVector
~BitVector();
/// Constructs a bit vector from the file name
in Directory
/// d
, as written by the; method.
BitVector(CL_NS(store)::Directory* d, const char* name);
/// Sets the value of bit
to one.
void set(const int32_t bit);
/// Sets the value of bit
to zero.
void clear(const int32_t bit);
/// Returns true
if bit
is one and
/// false
if it is zero.
bool get(const int32_t bit);
/// Returns the number of bits in this vector. This is also one greater than
/// the number of the largest valid bit number.
int32_t size();
/// Returns the total number of one bits in this vector. This is efficiently
/// computed and cached, so that, if the vector is not changed, no
/// recomputation is done for repeated calls.
int32_t count();
/// Writes this vector to the file name
in Directory
/// d
, in a format that can be read by the constructor {@link
/// #BitVector(Directory, String)}.
void write(CL_NS(store)::Directory* d, const char* name);
};
CL_NS_END
#endif