\doxysection{bitvec.\+h}
\label{bitvec_8h_source}\index{include/sphinxbase/bitvec.h@{include/sphinxbase/bitvec.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{/*\ -\/*-\/\ c-\/basic-\/offset:\ 4;\ indent-\/tabs-\/mode:\ nil\ -\/*-\/\ */}}
\DoxyCodeLine{00002\ \textcolor{comment}{/*\ ====================================================================}}
\DoxyCodeLine{00003\ \textcolor{comment}{\ *\ Copyright\ (c)\ 1999-\/2004\ Carnegie\ Mellon\ University.\ \ All\ rights}}
\DoxyCodeLine{00004\ \textcolor{comment}{\ *\ reserved.}}
\DoxyCodeLine{00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00006\ \textcolor{comment}{\ *\ Redistribution\ and\ use\ in\ source\ and\ binary\ forms,\ with\ or\ without}}
\DoxyCodeLine{00007\ \textcolor{comment}{\ *\ modification,\ are\ permitted\ provided\ that\ the\ following\ conditions}}
\DoxyCodeLine{00008\ \textcolor{comment}{\ *\ are\ met:}}
\DoxyCodeLine{00009\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00010\ \textcolor{comment}{\ *\ 1.\ Redistributions\ of\ source\ code\ must\ retain\ the\ above\ copyright}}
\DoxyCodeLine{00011\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer.\ }}
\DoxyCodeLine{00012\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00013\ \textcolor{comment}{\ *\ 2.\ Redistributions\ in\ binary\ form\ must\ reproduce\ the\ above\ copyright}}
\DoxyCodeLine{00014\ \textcolor{comment}{\ *\ \ \ \ notice,\ this\ list\ of\ conditions\ and\ the\ following\ disclaimer\ in}}
\DoxyCodeLine{00015\ \textcolor{comment}{\ *\ \ \ \ the\ documentation\ and/or\ other\ materials\ provided\ with\ the}}
\DoxyCodeLine{00016\ \textcolor{comment}{\ *\ \ \ \ distribution.}}
\DoxyCodeLine{00017\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00018\ \textcolor{comment}{\ *\ This\ work\ was\ supported\ in\ part\ by\ funding\ from\ the\ Defense\ Advanced\ }}
\DoxyCodeLine{00019\ \textcolor{comment}{\ *\ Research\ Projects\ Agency\ and\ the\ National\ Science\ Foundation\ of\ the\ }}
\DoxyCodeLine{00020\ \textcolor{comment}{\ *\ United\ States\ of\ America,\ and\ the\ CMU\ Sphinx\ Speech\ Consortium.}}
\DoxyCodeLine{00021\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00022\ \textcolor{comment}{\ *\ THIS\ SOFTWARE\ IS\ PROVIDED\ BY\ CARNEGIE\ MELLON\ UNIVERSITY\ \`{}\`{}AS\ IS''\ AND\ }}
\DoxyCodeLine{00023\ \textcolor{comment}{\ *\ ANY\ EXPRESSED\ OR\ IMPLIED\ WARRANTIES,\ INCLUDING,\ BUT\ NOT\ LIMITED\ TO,\ }}
\DoxyCodeLine{00024\ \textcolor{comment}{\ *\ THE\ IMPLIED\ WARRANTIES\ OF\ MERCHANTABILITY\ AND\ FITNESS\ FOR\ A\ PARTICULAR}}
\DoxyCodeLine{00025\ \textcolor{comment}{\ *\ PURPOSE\ ARE\ DISCLAIMED.\ \ IN\ NO\ EVENT\ SHALL\ CARNEGIE\ MELLON\ UNIVERSITY}}
\DoxyCodeLine{00026\ \textcolor{comment}{\ *\ NOR\ ITS\ EMPLOYEES\ BE\ LIABLE\ FOR\ ANY\ DIRECT,\ INDIRECT,\ INCIDENTAL,}}
\DoxyCodeLine{00027\ \textcolor{comment}{\ *\ SPECIAL,\ EXEMPLARY,\ OR\ CONSEQUENTIAL\ DAMAGES\ (INCLUDING,\ BUT\ NOT\ }}
\DoxyCodeLine{00028\ \textcolor{comment}{\ *\ LIMITED\ TO,\ PROCUREMENT\ OF\ SUBSTITUTE\ GOODS\ OR\ SERVICES;\ LOSS\ OF\ USE,\ }}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *\ DATA,\ OR\ PROFITS;\ OR\ BUSINESS\ INTERRUPTION)\ HOWEVER\ CAUSED\ AND\ ON\ ANY\ }}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ THEORY\ OF\ LIABILITY,\ WHETHER\ IN\ CONTRACT,\ STRICT\ LIABILITY,\ OR\ TORT\ }}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ (INCLUDING\ NEGLIGENCE\ OR\ OTHERWISE)\ ARISING\ IN\ ANY\ WAY\ OUT\ OF\ THE\ USE\ }}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ OF\ THIS\ SOFTWARE,\ EVEN\ IF\ ADVISED\ OF\ THE\ POSSIBILITY\ OF\ SUCH\ DAMAGE.}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ ====================================================================}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#ifndef\ \_LIBUTIL\_BITVEC\_H\_}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#define\ \_LIBUTIL\_BITVEC\_H\_}}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{preprocessor}{\#include\ <string.h>}}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ \textcolor{comment}{/*\ Win32/WinCE\ DLL\ gunk\ */}}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#include\ <sphinxbase/sphinxbase\_export.h>}}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#include\ <sphinxbase/prim\_type.h>}}
\DoxyCodeLine{00047\ \textcolor{preprocessor}{\#include\ <sphinxbase/ckd\_alloc.h>}}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00056\ \textcolor{preprocessor}{\#ifdef\ \_\_cplusplus}}
\DoxyCodeLine{00057\ \textcolor{keyword}{extern}\ \textcolor{stringliteral}{"{}C"{}}\ \{}
\DoxyCodeLine{00058\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00059\ \textcolor{preprocessor}{\#if\ 0}}
\DoxyCodeLine{00060\ \textcolor{comment}{/*\ Fool\ Emacs.\ */}}
\DoxyCodeLine{00061\ \}}
\DoxyCodeLine{00062\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \textcolor{preprocessor}{\#define\ BITVEC\_BITS\ 32}}
\DoxyCodeLine{00065\ \textcolor{keyword}{typedef}\ uint32\ bitvec\_t;}
\DoxyCodeLine{00066\ }
\DoxyCodeLine{00070\ \textcolor{preprocessor}{\#define\ bitvec\_size(n)\ \ \ \ \ \ \ \ \ \ (((n)+BITVEC\_BITS-\/1)/BITVEC\_BITS)}}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#define\ bitvec\_alloc(n)\ \ \ \ \ \ \ \ \ ckd\_calloc(bitvec\_size(n),\ sizeof(bitvec\_t))}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00080\ SPHINXBASE\_EXPORT}
\DoxyCodeLine{00081\ bitvec\_t\ *bitvec\_realloc(bitvec\_t\ *vec,\ \ \ \textcolor{comment}{/*\ In:\ Bit\ vector\ to\ search\ */}}
\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{size\_t}\ old\_len,\ \textcolor{comment}{/*\ In:\ Old\ length\ */}}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{size\_t}\ new\_len);\ \textcolor{comment}{/*\ In:\ New\ lenght\ of\ above\ bit\ vector\ */}}
\DoxyCodeLine{00087\ \textcolor{preprocessor}{\#define\ bitvec\_free(v)\ \ \ \ \ \ \ \ \ \ ckd\_free(v)}}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00095\ \textcolor{preprocessor}{\#define\ bitvec\_set(v,b)\ \ \ \ \ \ \ \ \ (v[(b)/BITVEC\_BITS]\ |=\ (1UL\ <<\ ((b)\ \&\ (BITVEC\_BITS-\/1))))}}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00103\ \textcolor{preprocessor}{\#define\ bitvec\_set\_all(v,n)\ \ \ \ \ memset(v,\ (bitvec\_t)-\/1,\ \(\backslash\)}}
\DoxyCodeLine{00104\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (((n)+BITVEC\_BITS-\/1)/BITVEC\_BITS)\ *\ \(\backslash\)}}
\DoxyCodeLine{00105\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sizeof(bitvec\_t))}}
\DoxyCodeLine{00112\ \textcolor{preprocessor}{\#define\ bitvec\_clear(v,b)\ \ \ \ \ \ \ (v[(b)/BITVEC\_BITS]\ \&=\ \string~(1UL\ <<\ ((b)\ \&\ (BITVEC\_BITS-\/1))))}}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00120\ \textcolor{preprocessor}{\#define\ bitvec\_clear\_all(v,n)\ \ \ memset(v,\ 0,\ (((n)+BITVEC\_BITS-\/1)/BITVEC\_BITS)\ *\ \(\backslash\)}}
\DoxyCodeLine{00121\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sizeof(bitvec\_t))}}
\DoxyCodeLine{00122\ }
\DoxyCodeLine{00129\ \textcolor{preprocessor}{\#define\ bitvec\_is\_set(v,b)\ \ \ \ \ \ (v[(b)/BITVEC\_BITS]\ \&\ (1UL\ <<\ ((b)\ \&\ (BITVEC\_BITS-\/1))))}}
\DoxyCodeLine{00130\ }
\DoxyCodeLine{00137\ \textcolor{preprocessor}{\#define\ bitvec\_is\_clear(v,b)\ \ \ \ (!\ (bitvec\_is\_set(v,b)))}}
\DoxyCodeLine{00138\ }
\DoxyCodeLine{00139\ }
\DoxyCodeLine{00147\ SPHINXBASE\_EXPORT}
\DoxyCodeLine{00148\ \textcolor{keywordtype}{size\_t}\ bitvec\_count\_set(bitvec\_t\ *vec,\ \ \textcolor{comment}{/*\ In:\ Bit\ vector\ to\ search\ */}}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{size\_t}\ len);\ \ \ \ \textcolor{comment}{/*\ In:\ Lenght\ of\ above\ bit\ vector\ */}}
\DoxyCodeLine{00150\ }
\DoxyCodeLine{00151\ \textcolor{preprocessor}{\#ifdef\ \_\_cplusplus}}
\DoxyCodeLine{00152\ \}}
\DoxyCodeLine{00153\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00154\ }
\DoxyCodeLine{00155\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
