1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package eu.simuline.octave.type.matrix;
17
18 import eu.simuline.octave.util.StringUtil;
19
20 import it.unimi.dsi.fastutil.objects.ObjectArrayList;
21
22 import java.util.List;
23 import java.util.Objects;
24
25
26
27
28
29
30
31
32
33
34 public abstract class AbstractObjectMatrix<T>
35 extends AbstractGenericMatrix<T[], ObjectArrayList<T>> {
36
37
38
39
40
41 protected AbstractObjectMatrix(final int... size) {
42 super(size);
43 }
44
45
46
47
48
49
50 @SuppressWarnings("unchecked")
51 protected AbstractObjectMatrix(final Object[] dataA, final int... size) {
52 super((T[]) dataA, size);
53 }
54
55
56
57
58
59
60
61 protected AbstractObjectMatrix(final AbstractGenericMatrix<T[], ObjectArrayList<T>> o) {
62 super(o);
63 }
64
65
66 protected final ObjectArrayList<T> newL(final int size) {
67 ObjectArrayList<T> list = new ObjectArrayList<T>(size);
68 list.size(size);
69 return list;
70 }
71
72
73 protected final int initL(T[] data, final int size) {
74 this.dataL = new ObjectArrayList<T>(data);
75 this.dataL.size(size);
76 return data.length;
77 }
78
79
80 protected T[] getDataA() {
81 return this.dataL.elements();
82 }
83
84
85
86
87
88
89
90
91
92
93
94
95 @SuppressWarnings("checkstyle:designforextension")
96 public void set(final T value, final int... pos) {
97 resizeUp(pos);
98 setPlain(value, pos2ind(pos));
99 }
100
101
102
103
104
105
106
107
108 public final void setPlain(final T value, final int pos) {
109 this.dataL.set(pos, value);
110 }
111
112
113 public final void setPlain(final String value, final int pos) {
114 throw new UnsupportedOperationException();
115 }
116
117
118
119
120
121
122
123
124
125 @SuppressWarnings("checkstyle:designforextension")
126 public T get(final int... pos) {
127 return this.dataL.get(pos2ind(pos));
128 }
129
130
131 public final String getPlainString(int pos) {
132 return StringUtil.toString(this.dataL.get(pos));
133 }
134 }