@@ -42,6 +42,35 @@ public static LibraryFactory<ArrayStoreLibrary> getFactory() {
42
42
return FACTORY ;
43
43
}
44
44
45
+ public static Object initialStorage (boolean shared ) {
46
+ if (shared ) {
47
+ return SHARED_INITIAL_STORE ;
48
+ } else {
49
+ return INITIAL_STORE ;
50
+ }
51
+ }
52
+
53
+ public static ArrayAllocator initialAllocator (boolean shared ) {
54
+ if (shared ) {
55
+ return SHARED_INITIAL_ALLOCATOR ;
56
+ } else {
57
+ return INITIAL_ALLOCATOR ;
58
+ }
59
+ }
60
+
61
+ /** Return an allocator for storage that can hold {@code value}. */
62
+ public static ArrayAllocator allocatorForValue (Object value ) {
63
+ if (value instanceof Integer ) {
64
+ return IntegerArrayStore .INTEGER_ARRAY_ALLOCATOR ;
65
+ } else if (value instanceof Long ) {
66
+ return LongArrayStore .LONG_ARRAY_ALLOCATOR ;
67
+ } else if (value instanceof Double ) {
68
+ return DoubleArrayStore .DOUBLE_ARRAY_ALLOCATOR ;
69
+ } else {
70
+ return ObjectArrayStore .OBJECT_ARRAY_ALLOCATOR ;
71
+ }
72
+ }
73
+
45
74
/** Read the value from {@code index} of {@code store}. */
46
75
public abstract Object read (Object store , int index );
47
76
@@ -86,22 +115,6 @@ public Object initialStore(Object store) {
86
115
return INITIAL_STORE ;
87
116
}
88
117
89
- public static Object initialStorage (boolean shared ) {
90
- if (shared ) {
91
- return SHARED_INITIAL_STORE ;
92
- } else {
93
- return INITIAL_STORE ;
94
- }
95
- }
96
-
97
- public static ArrayAllocator initialAllocator (boolean shared ) {
98
- if (shared ) {
99
- return SHARED_INITIAL_ALLOCATOR ;
100
- } else {
101
- return INITIAL_ALLOCATOR ;
102
- }
103
- }
104
-
105
118
/** Return whether {@code store} and {@code other} share the same underlying array storage. */
106
119
public abstract boolean isSameStorage (Object store , Object other );
107
120
@@ -218,19 +231,6 @@ public ArrayAllocator unsharedAllocator(Object store) {
218
231
/** Return whether the {@code store}'s default value is {@code value}. */
219
232
public abstract boolean isDefaultValue (Object store , Object value );
220
233
221
- /** Return an allocator for storage that can hold {@code value}. */
222
- public static ArrayAllocator allocatorForValue (Object value ) {
223
- if (value instanceof Integer ) {
224
- return IntegerArrayStore .INTEGER_ARRAY_ALLOCATOR ;
225
- } else if (value instanceof Long ) {
226
- return LongArrayStore .LONG_ARRAY_ALLOCATOR ;
227
- } else if (value instanceof Double ) {
228
- return DoubleArrayStore .DOUBLE_ARRAY_ALLOCATOR ;
229
- } else {
230
- return ObjectArrayStore .OBJECT_ARRAY_ALLOCATOR ;
231
- }
232
- }
233
-
234
234
/** Class for allocating array stores and querying properties related to that. */
235
235
public abstract static class ArrayAllocator {
236
236
0 commit comments