DayZ 1.24
Loading...
Searching...
No Matches
BitArray Class Reference

Static Private Member Functions

static int IDToIndex (int id)
 
static int IDToMask (int id)
 
static array< intCreateMaskArray (int size)
 Creates an array which will be able to accomodate 'size' number of unique IDs.
 
static int GetBitCount (array< int > bit_array)
 Returns number of bits this array can hold.
 
static int IDToNumOfItems (int id)
 Returns number of INTs required to hold this ID minus 1(ie for 32, the result is 0, for 33, the result is 1)
 
static array< intCreateArrayWithID (int id)
 
static bool IsMaskContainID (array< int > bit_array, int id)
 
static bool AddIDToMask (array< int > bit_array, int id)
 

Detailed Description

Definition at line 5 of file BitArray.c.

Member Function Documentation

◆ AddIDToMask()

static bool BitArray::AddIDToMask ( array< int > bit_array,
int id )
inlinestaticprivate

Definition at line 75 of file BitArray.c.

76 {
77 if (BitArray.IDToNumOfItems(id) > bit_array.Count())
78 return false;
79 else
80 {
82 int bit = BitArray.IDToMask(id);
85 return true;
86 }
87 }
static int IDToNumOfItems(int id)
Returns number of INTs required to hold this ID minus 1(ie for 32, the result is 0,...
Definition BitArray.c:38
static int IDToMask(int id)
Definition BitArray.c:14

References IDToMask(), and IDToNumOfItems().

◆ CreateArrayWithID()

static array< int > BitArray::CreateArrayWithID ( int id)
inlinestaticprivate

Definition at line 45 of file BitArray.c.

46 {
47 int m_NumOfItems = BitArray.IDToNumOfItems(id);//TODO: check for too big id
48 int bit = BitArray.IDToMask(id);
49
51
52 for (int i = 0; i <= m_NumOfItems; i++)
53 bit_array.Insert(0);
55 return bit_array;
56 }

References IDToMask(), and IDToNumOfItems().

◆ CreateMaskArray()

static array< int > BitArray::CreateMaskArray ( int size)
inlinestaticprivate

Creates an array which will be able to accomodate 'size' number of unique IDs.

Definition at line 21 of file BitArray.c.

22 {
25
26 for (int i = 0; i <= m_NumOfItems; i++)
27 bit_array.Insert(0);
28
29 return bit_array;
30 }

References IDToNumOfItems().

◆ GetBitCount()

static int BitArray::GetBitCount ( array< int > bit_array)
inlinestaticprivate

Returns number of bits this array can hold.

Definition at line 32 of file BitArray.c.

33 {
34 return ((bit_array.Count()) * BIT_INT_SIZE);
35 }
const int BIT_INT_SIZE
Definition BitArray.c:4

References BIT_INT_SIZE.

◆ IDToIndex()

static int BitArray::IDToIndex ( int id)
inlinestaticprivate

Definition at line 7 of file BitArray.c.

8 {
10 int index = (id - (m_NumOfItems * BIT_INT_SIZE)) - 1;
11 return index;
12 }

References BIT_INT_SIZE, and IDToNumOfItems().

Referenced by IDToMask().

◆ IDToMask()

static int BitArray::IDToMask ( int id)
inlinestaticprivate

Definition at line 14 of file BitArray.c.

15 {
16 int index = BitArray.IDToIndex(id);
17 int bit = 1 << index;
18 return bit;
19 }
static int IDToIndex(int id)
Definition BitArray.c:7

References IDToIndex().

Referenced by AddIDToMask(), CreateArrayWithID(), and IsMaskContainID().

◆ IDToNumOfItems()

static int BitArray::IDToNumOfItems ( int id)
inlinestaticprivate

Returns number of INTs required to hold this ID minus 1(ie for 32, the result is 0, for 33, the result is 1)

Definition at line 38 of file BitArray.c.

39 {
40 int m_NumOfItems = id / BIT_INT_SIZE;
41 if (id % BIT_INT_SIZE == 0) m_NumOfItems--;
42 return m_NumOfItems;
43 }

References BIT_INT_SIZE.

Referenced by AddIDToMask(), CreateArrayWithID(), CreateMaskArray(), IDToIndex(), and IsMaskContainID().

◆ IsMaskContainID()

static bool BitArray::IsMaskContainID ( array< int > bit_array,
int id )
inlinestaticprivate

Definition at line 58 of file BitArray.c.

59 {
60 if (BitArray.IDToNumOfItems(id) > bit_array.Count())
61 return false;
62 else
63 {
67
69 return true;
70 else
71 return false;
72 }
73 }

References IDToMask(), and IDToNumOfItems().


The documentation for this class was generated from the following file: