lib/antlr/src/BitSet.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
#include "antlr/BitSet.hpp"
00008
#include <string>
00009
00010
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00011
namespace antlr {
00012
#endif
00013
00014 BitSet::BitSet(
unsigned int nbits)
00015 : storage(nbits)
00016 {
00017
for (
unsigned int i = 0; i < nbits ; i++ )
00018
storage[i] =
false;
00019 }
00020
00021 BitSet::BitSet(
const unsigned long* bits_,
unsigned int nlongs )
00022 : storage(nlongs*32)
00023 {
00024
for (
unsigned int i = 0 ; i < (nlongs * 32); i++)
00025
storage[i] = (bits_[i>>5] & (1UL << (i&31))) ?
true :
false;
00026 }
00027
00028 BitSet::~BitSet()
00029 {
00030 }
00031
00032 void BitSet::add(
unsigned int el)
00033 {
00034
if( el >=
storage.size() )
00035
storage.resize( el+1,
false );
00036
00037
storage[el] =
true;
00038 }
00039
00040 bool BitSet::member(
unsigned int el)
const
00041
{
00042
if ( el >=
storage.size())
00043
return false;
00044
00045
return storage[el];
00046 }
00047
00048 ANTLR_USE_NAMESPACE(std)vector<
unsigned int>
BitSet::toArray()
const
00049
{
00050
ANTLR_USE_NAMESPACE(std)vector<unsigned int> elems;
00051
for (
unsigned int i = 0; i < storage.size(); i++)
00052 {
00053
if (storage[i])
00054 elems.push_back(i);
00055 }
00056
00057
return elems;
00058 }
00059
00060
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00061
}
00062
#endif
This file is part of the documentation for KDevelop Version 3.0.4.