-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuperBlock.java
57 lines (49 loc) · 1.98 KB
/
SuperBlock.java
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
public class SuperBlock {
protected int number; // as in S0, S1, etc.
protected int maxNumberOfDataBlocks;
// number of elements per Block
protected int maxNumberOfElementsPerBlock;
// current number of Blocks in this SuperBlock
protected int currentNumberOfDataBlocks;
// Workhorse constructor. Initialize variables.
public SuperBlock(int number, int maxNumberOfDataBlocks,
int maxNumberOfElementsPerBlock, int currentNumberOfDataBlocks) {
this.number = number;
this.maxNumberOfDataBlocks = maxNumberOfDataBlocks;
this.maxNumberOfElementsPerBlock = maxNumberOfElementsPerBlock;
this.currentNumberOfDataBlocks = currentNumberOfDataBlocks;
}
// Returns number.
public int getNumber() {
return number;
}
// Returns maxNumberOfDataBlocks
public int getMaxNumberOfDataBlocks() {
return maxNumberOfDataBlocks;
}
// Returns maxNumberOfElementsPerBlock
public int getMaxNumberOfElementsPerBlock() {
return maxNumberOfElementsPerBlock;
}
// Returns currentNumberOfDataBlocks
public int getCurrentNumberOfDataBlocks() {
return currentNumberOfDataBlocks;
}
// Increments CurrentNumberOfDataBlocks
public void incrementCurrentNumberOfDataBlocks() {
++currentNumberOfDataBlocks;
}
// Decrements currentNumberOfDataBlocks
public void decrementCurrentNumberOfDataBlocks() {
--currentNumberOfDataBlocks;
}
// Create a pretty representation of the SuperBlock for debugging.
// Example:
// - maxNumberOfDataBlocks:2
// - maxNumberOfElementsPerBlock:2
// - currentNumberOfDataBlocks:1
protected String toStringForDebugging() {
return ("- maxNumberOfDataBlocks: " + maxNumberOfDataBlocks + "\n- maxNumberOfElementsPerBlock: "
+ maxNumberOfElementsPerBlock + "\n- currentNumberOfDataBlocks: " + currentNumberOfDataBlocks + "\n");
}
}