This source file includes following definitions.
- newData
- getValue
- getIndex
- putValue
- putIndex
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 DoubleInt extends Struct
27 {
28 private final int iOff, iSize;
29
30
31
32
33
34
35
36 protected DoubleInt(int intOff, int intSize)
37 {
38 int dOff = addDouble();
39 assert dOff == 0;
40
41 iSize = intSize;
42 setOffset(intOff);
43
44 switch(iSize)
45 {
46 case 4: iOff = addInt(); break;
47 case 8: iOff = addLong(); break;
48 default: throw new AssertionError("Unsupported int size: "+ iSize);
49 }
50
51 assert(intOff == iOff);
52 }
53
54
55
56
57
58 @Override protected DoubleInt.Data newData()
59 {
60 return new DoubleInt.Data();
61 }
62
63
64
65
66 public final class Data extends Struct.Data
67 {
68
69
70
71
72 public double getValue()
73 {
74 return getDouble(0);
75 }
76
77
78
79
80
81 public int getIndex()
82 {
83 switch(iSize)
84 {
85 case 4: return getInt(iOff);
86 case 8: return (int)getLong(iOff);
87 default: throw new AssertionError();
88 }
89 }
90
91
92
93
94
95 public void putValue(double v)
96 {
97 putDouble(0, v);
98 }
99
100
101
102
103
104 public void putIndex(int v)
105 {
106 switch(iSize)
107 {
108 case 4: putInt(iOff, v); break;
109 case 8: putLong(iOff, v); break;
110 default: throw new AssertionError();
111 }
112 }
113 }
114
115 }