~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/qdune/qdtl/boolarray.h

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//-----------------------------------------------------------------------------
2
 
// simple bool array, boolean values set as individual bits in int array.
3
 
//-----------------------------------------------------------------------------
4
 
 
5
 
#ifndef _BOOLARRAY_H
6
 
#define _BOOLARRAY_H
7
 
 
8
 
//#include <cassert>
9
 
 
10
 
#include "QDRender.h"
11
 
__BEGIN_QDRENDER
12
 
 
13
 
class boolarray_t
14
 
{
15
 
private:
16
 
        boolarray_t(const boolarray_t&);
17
 
public:
18
 
        boolarray_t() : ba(NULL), _size(0), _numbits(0) {}
19
 
        boolarray_t(unsigned int numbits) : ba(NULL), _size(0), _numbits(0) { resize(numbits); }
20
 
        ~boolarray_t() { if (ba) delete[] ba;  ba = NULL; }
21
 
        boolarray_t& operator=(const boolarray_t& ba2)
22
 
        {
23
 
                if (ba2._size != _size) {
24
 
                        if (ba) delete[] ba;
25
 
                        _size = ba2._size;
26
 
                        _numbits = ba2._numbits;
27
 
                        ba = new unsigned int[_size];
28
 
                }
29
 
                memcpy(ba, ba2.ba, _size*sizeof(unsigned int));
30
 
                return *this;
31
 
        }
32
 
        void resize(unsigned int numbits)
33
 
        {
34
 
                _numbits = numbits;
35
 
                _size = ((numbits ? numbits : 1) + 31) >> 5;
36
 
                if (ba) delete[] ba;
37
 
                ba = new unsigned int[_size];
38
 
                memset(ba, 0, _size*sizeof(unsigned int));
39
 
        }
40
 
        bool operator[](unsigned int i)
41
 
        {
42
 
                const unsigned int b = 1 << (i & 31);
43
 
                i >>= 5;
44
 
                //assert(i < _size);
45
 
                return (ba[i] & b);
46
 
        }
47
 
        void operator()(unsigned int i, bool bl)
48
 
        {
49
 
                const unsigned int b = 1 << (i & 31);
50
 
                i >>= 5;
51
 
                //assert(i < _size);
52
 
                if (bl)
53
 
                        ba[i] |= b;
54
 
                else
55
 
                        ba[i] &= ~b;
56
 
        }
57
 
        boolarray_t& operator|=(const boolarray_t& ba2)
58
 
        {
59
 
                //assert(ba2._size == _size);
60
 
                for (size_t i=0; i<_size; ++i)
61
 
                        ba[i] |= ba2.ba[i];
62
 
                return *this;
63
 
        }
64
 
        boolarray_t& operator&=(const boolarray_t& ba2)
65
 
        {
66
 
                //assert(ba2._size == _size);
67
 
                for (size_t i=0; i<_size; ++i)
68
 
                        ba[i] &= ba2.ba[i];
69
 
                return *this;
70
 
        }
71
 
        size_t size() const { return _numbits; }
72
 
protected:
73
 
        unsigned int *ba;
74
 
        size_t _size, _numbits;
75
 
};
76
 
 
77
 
__END_QDRENDER
78
 
 
79
 
#endif  // _BOOLARRAY_H