This source file includes following definitions.
- addIntField
- newData
- getValue
- getIndex
- putValue
- putIndex
- get
- put
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package mpi;
22
23
24
25
26 public final class Int2 extends Struct
27 {
28 private final int iOff, iSize;
29
30
31
32
33
34
35
36 protected Int2(int intOff, int intSize)
37 {
38 iSize = intSize;
39 int off = addIntField();
40 assert off == 0;
41 setOffset(intOff);
42 iOff = addIntField();
43 assert intOff == iOff;
44 }
45
46 private int addIntField()
47 {
48 switch(iSize)
49 {
50 case 4: return addInt();
51 case 8: return addLong();
52 default: throw new AssertionError("Unsupported int size: "+ iSize);
53 }
54 }
55
56
57
58
59
60 @Override protected Int2.Data newData()
61 {
62 return new Int2.Data();
63 }
64
65
66
67
68 public final class Data extends Struct.Data
69 {
70
71
72
73
74 public int getValue()
75 {
76 return get(0);
77 }
78
79
80
81
82
83 public int getIndex()
84 {
85 return get(iOff);
86 }
87
88
89
90
91
92 public void putValue(int v)
93 {
94 put(0, v);
95 }
96
97
98
99
100
101 public void putIndex(int v)
102 {
103 put(iOff, v);
104 }
105
106 private int get(int off)
107 {
108 switch(iSize)
109 {
110 case 4: return getInt(off);
111 case 8: return (int)getLong(off);
112 default: throw new AssertionError();
113 }
114 }
115
116 private void put(int off, int v)
117 {
118 switch(iSize)
119 {
120 case 4: putInt(off, v); break;
121 case 8: putLong(off, v); break;
122 default: throw new AssertionError();
123 }
124 }
125 }
126
127 }