-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPage.cs
More file actions
63 lines (51 loc) · 1.72 KB
/
Page.cs
File metadata and controls
63 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
namespace Virtual_array
{
public struct Page
{
public int PageNumber { get; }
public bool IsModifited { get; set; }
public DateTime RecordingDate { get; private set; }
public Byte [] BitMap { get; }
public int [] Elements { get; }
public Page(int pageNumber, int pageSizeInByte, int bitMapSize, int elementsCountOnPage)
{
if (pageNumber < 0)
throw new ArgumentException("Wrong page number");
else if (pageSizeInByte < 0)
throw new ArgumentException("Wrong page size");
else
{
PageNumber = pageNumber;
IsModifited = false;
RecordingDate = DateTime.Now;
BitMap = new Byte[bitMapSize];
Elements = new int[elementsCountOnPage];
}
}
public void UpdateRecordingDate()
{
RecordingDate = DateTime.Now;
}
public void SetBitMapData(Byte[] outputBitMap)
{
outputBitMap.CopyTo(BitMap, 0);
}
public void SetElementsData(int[] outputElements)
{
outputElements.CopyTo(Elements, 0);
}
public bool CheckBit(int bitMapByteIndex, int discharge)
{
int checker = (int)Math.Pow(2, discharge);
if ((BitMap[bitMapByteIndex] & checker) == checker)
return true;
else return false;
}
public void SetBit(int bitMapByteIndex, int discharge)
{
int setter = (int)Math.Pow(2, discharge);
BitMap[bitMapByteIndex] = (Byte)(BitMap[bitMapByteIndex] | setter);
}
}
}