Home
last modified time | relevance | path

Searched refs:array (Results 1 – 25 of 215) sorted by relevance

123456789

/libcore/ojluni/src/main/java/java/lang/reflect/
DArray.java137 public static int getLength(Object array) in getLength() argument
139 if (array instanceof Object[]) { in getLength()
140 return ((Object[]) array).length; in getLength()
141 } else if (array instanceof boolean[]) { in getLength()
142 return ((boolean[]) array).length; in getLength()
143 } else if (array instanceof byte[]) { in getLength()
144 return ((byte[]) array).length; in getLength()
145 } else if (array instanceof char[]) { in getLength()
146 return ((char[]) array).length; in getLength()
147 } else if (array instanceof double[]) { in getLength()
[all …]
/libcore/json/src/test/java/libcore/org/json/
DJSONArrayTest.java36 JSONArray array = new JSONArray(); in testEmptyArray() local
37 assertEquals(0, array.length()); in testEmptyArray()
38 assertEquals("", array.join(" AND ")); in testEmptyArray()
40 array.get(0); in testEmptyArray()
45 array.getBoolean(0); in testEmptyArray()
50 assertEquals("[]", array.toString()); in testEmptyArray()
51 assertEquals("[]", array.toString(4)); in testEmptyArray()
54 assertTrue(array.isNull(0)); in testEmptyArray()
55 assertNull(array.opt(0)); in testEmptyArray()
56 assertFalse(array.optBoolean(0)); in testEmptyArray()
[all …]
DSelfUseTest.java82 private final JSONArray array = new JSONArray() { field in SelfUseTest
166 array.put("foo"); in testToJSONArray()
167 array.put("baz"); in testToJSONArray()
168 array.put("bar"); in testToJSONArray()
169 object.toJSONArray(array); in testToJSONArray()
177 array.put(10, false); in testPutAtIndex()
182 array.isNull(5); in testIsNull()
187 array.put(true); in testArrayGetType()
188 array.getBoolean(0); in testArrayGetType()
193 array.optBoolean(3); in testArrayOptType()
[all …]
DParsingTest.java155 assertParsed(array(), "[]"); in testParsingArrays()
156 assertParsed(array(5, 6, true), "[5,6,true]"); in testParsingArrays()
157 assertParsed(array(5, 6, array()), "[5,6,[]]"); in testParsingArrays()
158 assertParsed(array(5, 6, 7), "[5;6;7]"); in testParsingArrays()
159 assertParsed(array(5, 6, 7), "[5 , 6 \t; \r\n 7\n]"); in testParsingArrays()
160 assertParsed(array(5, 6, 7, null), "[5,6,7,]"); in testParsingArrays()
161 assertParsed(array(null, null), "[,]"); in testParsingArrays()
162 assertParsed(array(5, null, null, null, 5), "[5,,,,5]"); in testParsingArrays()
163 assertParsed(array(null, 5), "[,5]"); in testParsingArrays()
164 assertParsed(array(null, null, null), "[,,]"); in testParsingArrays()
[all …]
/libcore/luni/src/test/java/libcore/java/util/
DOldAndroidArrayListTest.java30 ArrayList array = new ArrayList(); in testArrayList() local
31 assertEquals(0, array.size()); in testArrayList()
32 assertTrue(array.isEmpty()); in testArrayList()
34 array.add(new Integer(0)); in testArrayList()
35 array.add(0, new Integer(1)); in testArrayList()
36 array.add(1, new Integer(2)); in testArrayList()
37 array.add(new Integer(3)); in testArrayList()
38 array.add(new Integer(1)); in testArrayList()
40 assertEquals(5, array.size()); in testArrayList()
41 assertFalse(array.isEmpty()); in testArrayList()
[all …]
/libcore/benchmarks/src/benchmarks/
DDeepArrayOpsBenchmark.java29 private Object[] array; field in DeepArrayOpsBenchmark
33 array = new Object[arrayLength * 14]; in setUp()
36 array[i] = new IntWrapper(i); in setUp()
39 array[i + 1] = new16ElementObjectarray(); in setUp()
42 array[i + 2] = new boolean[16]; in setUp()
45 array[i + 3] = new byte[16]; in setUp()
48 array[i + 4] = new char[16]; in setUp()
51 array[i + 5] = new short[16]; in setUp()
54 array[i + 6] = new float[16]; in setUp()
57 array[i + 7] = new long[16]; in setUp()
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/
DPriorityQueueTest.java46 Integer[] array = { 2, 45, 7, -12, 9 }; in test_iterator() local
47 for (int i = 0; i < array.length; i++) { in test_iterator()
48 integerQueue.offer(array[i]); in test_iterator()
57 Arrays.sort(array); in test_iterator()
59 assertTrue(Arrays.equals(array, resultArray)); in test_iterator()
115 Integer[] array = { 2, 45, 7, -12, 9 }; in test_iterator_remove() local
116 for (int i = 0; i < array.length; i++) { in test_iterator_remove()
117 integerQueue.offer(array[i]); in test_iterator_remove()
121 for (int i = 0; i < array.length; i++) { in test_iterator_remove()
127 assertEquals(array.length - 1, integerQueue.size()); in test_iterator_remove()
[all …]
/libcore/ojluni/src/main/java/java/util/stream/
DNodes.java139 static <T> Node<T> node(T[] array) { in node() argument
140 return new ArrayNode<>(array); in node()
192 static Node.OfInt node(int[] array) { in node() argument
193 return new IntArrayNode(array); in node()
229 static Node.OfLong node(final long[] array) { in node() argument
230 return new LongArrayNode(array); in node()
266 static Node.OfDouble node(final double[] array) { in node() argument
267 return new DoubleArrayNode(array); in node()
324 P_OUT[] array = generator.apply((int) size); in collect() local
325 new SizedCollectorTask.OfRef<>(spliterator, helper, array).invoke(); in collect()
[all …]
/libcore/ojluni/src/test/java/util/stream/boottest/java/util/stream/
DDoubleNodeTest.java43 double[] array = new double[size]; in createSizes() local
44 for (int i = 0; i < array.length; i++) { in createSizes()
45 array[i] = i; in createSizes()
50 nodes.add(Nodes.node(array)); in createSizes()
51 nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); in createSizes()
52 nodes.add(tree(toList(array), l -> Nodes.node(toDoubleArray(l)))); in createSizes()
53 nodes.add(fill(array, Nodes.doubleBuilder(array.length))); in createSizes()
54 nodes.add(fill(array, Nodes.doubleBuilder())); in createSizes()
57 params.add(new Object[]{array, node}); in createSizes()
65 private static void assertEqualsListDoubleArray(List<Double> list, double[] array) { in assertEqualsListDoubleArray() argument
[all …]
DLongNodeTest.java43 long[] array = new long[size]; in createSizes() local
44 for (int i = 0; i < array.length; i++) { in createSizes()
45 array[i] = i; in createSizes()
50 nodes.add(Nodes.node(array)); in createSizes()
51 nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); in createSizes()
52 nodes.add(tree(toList(array), l -> Nodes.node(toLongArray(l)))); in createSizes()
53 nodes.add(fill(array, Nodes.longBuilder(array.length))); in createSizes()
54 nodes.add(fill(array, Nodes.longBuilder())); in createSizes()
57 params.add(new Object[]{array, node}); in createSizes()
65 private static void assertEqualsListLongArray(List<Long> list, long[] array) { in assertEqualsListLongArray() argument
[all …]
DIntNodeTest.java43 int[] array = new int[size]; in createSizes() local
44 for (int i = 0; i < array.length; i++) { in createSizes()
45 array[i] = i; in createSizes()
50 nodes.add(Nodes.node(array)); in createSizes()
51 nodes.add(degenerateTree(Spliterators.iterator(Arrays.spliterator(array)))); in createSizes()
52 nodes.add(tree(toList(array), l -> Nodes.node(toIntArray(l)))); in createSizes()
53 nodes.add(fill(array, Nodes.intBuilder(array.length))); in createSizes()
54 nodes.add(fill(array, Nodes.intBuilder())); in createSizes()
57 params.add(new Object[]{array, node}); in createSizes()
65 private static void assertEqualsListIntArray(List<Integer> list, int[] array) { in assertEqualsListIntArray() argument
[all …]
DNodeTest.java43 Integer[] array = new Integer[size]; in createSizes() local
44 for (int i = 0; i < array.length; i++) { in createSizes()
45 array[i] = i; in createSizes()
49 nodes.add(Nodes.node(array)); in createSizes()
50 nodes.add(Nodes.node(Arrays.asList(array))); in createSizes()
51 nodes.add(degenerateTree(Arrays.asList(array).iterator())); in createSizes()
52 … nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l.toArray(new Integer[l.size()])))); in createSizes()
53 nodes.add(tree(Arrays.asList(array), l -> Nodes.node(l))); in createSizes()
54 … nodes.add(fill(array, Nodes.builder(array.length, LambdaTestHelpers.integerArrayGenerator))); in createSizes()
55 nodes.add(fill(array, Nodes.builder())); in createSizes()
[all …]
DSpinedBufferTest.java65 int[] array = IntStream.range(0, size).toArray(); in createSpinedBuffer() local
68 Arrays.stream(array).boxed().forEach(sb); in createSpinedBuffer()
69 params.add(new Object[]{array, sb}); in createSpinedBuffer()
72 Arrays.stream(array).boxed().forEach(sb); in createSpinedBuffer()
73 params.add(new Object[]{array, sb}); in createSpinedBuffer()
76 Arrays.stream(array).boxed().forEach(sb); in createSpinedBuffer()
77 params.add(new Object[]{array, sb}); in createSpinedBuffer()
80 Arrays.stream(array).boxed().forEach(sb); in createSpinedBuffer()
81 params.add(new Object[]{array, sb}); in createSpinedBuffer()
88 public void testSpliterator(int[] array, SpinedBuffer<Integer> sb) { in testSpliterator() argument
[all …]
/libcore/ojluni/src/main/java/java/util/concurrent/
DPriorityBlockingQueue.java288 private void tryGrow(Object[] array, int oldCap) { in tryGrow() argument
303 if (newCap > oldCap && queue == array) in tryGrow()
312 if (newArray != null && queue == array) { in tryGrow()
314 System.arraycopy(array, 0, newArray, 0, oldCap); in tryGrow()
326 Object[] array = queue; in dequeue() local
327 E result = (E) array[0]; in dequeue()
328 E x = (E) array[n]; in dequeue()
329 array[n] = null; in dequeue()
332 siftDownComparable(0, x, array, n); in dequeue()
334 siftDownUsingComparator(0, x, array, n, cmp); in dequeue()
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/nio/
DLongBufferTest.java51 long array[] = buf.array(); in testArray() local
52 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
54 loadTestData1(array, buf.arrayOffset(), buf.capacity()); in testArray()
55 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
57 loadTestData2(array, buf.arrayOffset(), buf.capacity()); in testArray()
58 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
61 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
64 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
68 long array[] = buf.array(); in testArrayOffset() local
69 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArrayOffset()
[all …]
DFloatBufferTest.java51 float array[] = buf.array(); in testArray() local
52 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
54 loadTestData1(array, buf.arrayOffset(), buf.capacity()); in testArray()
55 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
57 loadTestData2(array, buf.arrayOffset(), buf.capacity()); in testArray()
58 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
61 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
64 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
68 float array[] = buf.array(); in testArrayOffset() local
69 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArrayOffset()
[all …]
DIntBufferTest.java51 int array[] = buf.array(); in testArray() local
52 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
54 loadTestData1(array, buf.arrayOffset(), buf.capacity()); in testArray()
55 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
57 loadTestData2(array, buf.arrayOffset(), buf.capacity()); in testArray()
58 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
61 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
64 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
68 int array[] = buf.array(); in testArrayOffset() local
69 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArrayOffset()
[all …]
DDoubleBufferTest.java75 double array[] = buf.array(); in testArray() local
76 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
78 loadTestData1(array, buf.arrayOffset(), buf.capacity()); in testArray()
79 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
81 loadTestData2(array, buf.arrayOffset(), buf.capacity()); in testArray()
82 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
85 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
88 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
92 double array[] = buf.array(); in testArrayOffset() local
93 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArrayOffset()
[all …]
DShortBufferTest.java50 short array[] = buf.array(); in testArray() local
51 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
53 loadTestData1(array, buf.arrayOffset(), buf.capacity()); in testArray()
54 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
56 loadTestData2(array, buf.arrayOffset(), buf.capacity()); in testArray()
57 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
60 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
63 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArray()
67 short array[] = buf.array(); in testArrayOffset() local
68 assertContentEquals(buf, array, buf.arrayOffset(), buf.capacity()); in testArrayOffset()
[all …]
/libcore/luni/src/test/java/libcore/dalvik/system/
DVMRuntimeTest.java32 Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, -1); in doTestNewNonMovableArray() local
38 … Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, Integer.MIN_VALUE); in doTestNewNonMovableArray() local
45 Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, i); in doTestNewNonMovableArray() local
46 assertTrue(array.getClass().isArray()); in doTestNewNonMovableArray()
47 assertEquals(array.getClass().getComponentType(), componentType); in doTestNewNonMovableArray()
48 assertEquals(Array.getLength(array), i); in doTestNewNonMovableArray()
55 Object array = VMRuntime.getRuntime().newNonMovableArray(null, 0); in testNewNonMovableArray() local
62 Object array = VMRuntime.getRuntime().newNonMovableArray(void.class, 0); in testNewNonMovableArray() local
86 Object array = VMRuntime.getRuntime().newUnpaddedArray(componentType, -1); in doTestNewUnpaddedArray() local
92 … Object array = VMRuntime.getRuntime().newUnpaddedArray(componentType, Integer.MIN_VALUE); in doTestNewUnpaddedArray() local
[all …]
/libcore/ojluni/annotations/sdk/nullability/java/lang/reflect/
DArray.annotated.java40 public static int getLength(@libcore.util.NonNull java.lang.Object array) { throw new RuntimeExcept… in getLength() argument
42 …public static java.lang.Object get(@libcore.util.NonNull java.lang.Object array, int index) throws… in get() argument
44 public static boolean getBoolean(@libcore.util.NonNull java.lang.Object array, int index) throws ja… in getBoolean() argument
46 public static byte getByte(@libcore.util.NonNull java.lang.Object array, int index) throws java.lan… in getByte() argument
48 public static char getChar(@libcore.util.NonNull java.lang.Object array, int index) throws java.lan… in getChar() argument
50 public static short getShort(@libcore.util.NonNull java.lang.Object array, int index) throws java.l… in getShort() argument
52 public static int getInt(@libcore.util.NonNull java.lang.Object array, int index) throws java.lang.… in getInt() argument
54 public static long getLong(@libcore.util.NonNull java.lang.Object array, int index) throws java.lan… in getLong() argument
56 public static float getFloat(@libcore.util.NonNull java.lang.Object array, int index) throws java.l… in getFloat() argument
58 public static double getDouble(@libcore.util.NonNull java.lang.Object array, int index) throws java… in getDouble() argument
[all …]
/libcore/ojluni/src/test/java/util/stream/test/org/openjdk/tests/java/util/stream/
DDoublePrimitiveOpsTests.java47 double[] array = LongStream.range(1, 10).asDoubleStream().map(i -> i * 2).toArray(); in testToArray() local
48 assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
52 … double[] array = LongStream.range(1, 10).parallel().asDoubleStream().map(i -> i * 2).toArray(); in testToArray() local
53 assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
65 double[] array = Arrays.stream(content).sorted().toArray(); in testSort() local
66 assertEquals(array, sortedContent); in testSort()
70 double[] array = Arrays.stream(content).parallel().sorted().toArray(); in testSort() local
71 assertEquals(array, sortedContent); in testSort()
83 double[] array = Arrays.stream(content).sorted().sorted().toArray(); in testSortSort() local
84 assertEquals(array, sortedContent); in testSortSort()
[all …]
DIntPrimitiveOpsTests.java90 int[] array = IntStream.range(1, 10).map(i -> i * 2).toArray(); in testToArray() local
91 assertEquals(array, new int[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
95 int[] array = IntStream.range(1, 10).parallel().map(i -> i * 2).toArray(); in testToArray() local
96 assertEquals(array, new int[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
108 int[] array = Arrays.stream(content).sorted().toArray(); in testSort() local
109 assertEquals(array, sortedContent); in testSort()
113 int[] array = Arrays.stream(content).parallel().sorted().toArray(); in testSort() local
114 assertEquals(array, sortedContent); in testSort()
126 int[] array = Arrays.stream(content).sorted().sorted().toArray(); in testSortSort() local
127 assertEquals(array, sortedContent); in testSortSort()
[all …]
DLongPrimitiveOpsTests.java90 long[] array = LongStream.range(1, 10).map(i -> i * 2).toArray(); in testToArray() local
91 assertEquals(array, new long[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
95 long[] array = LongStream.range(1, 10).parallel().map(i -> i * 2).toArray(); in testToArray() local
96 assertEquals(array, new long[]{2, 4, 6, 8, 10, 12, 14, 16, 18}); in testToArray()
108 long[] array = Arrays.stream(content).sorted().toArray(); in testSort() local
109 assertEquals(array, sortedContent); in testSort()
113 long[] array = Arrays.stream(content).parallel().sorted().toArray(); in testSort() local
114 assertEquals(array, sortedContent); in testSort()
126 long[] array = Arrays.stream(content).sorted().sorted().toArray(); in testSortSort() local
127 assertEquals(array, sortedContent); in testSortSort()
[all …]
/libcore/luni/src/test/java/libcore/java/lang/reflect/
DOldAndroidArrayTest.java30 int[] array = (int[]) intArray; in testSingleInt() local
31 array[0] = 5; in testSingleInt()
35 assertEquals(6, array[1]); in testSingleInt()
38 array[2] = 27; in testSingleInt()
44 assertEquals(2, array.length); in testSingleInt()
45 assertEquals(Array.getLength(intArray), array.length); in testSingleInt()
61 String[] array = (String[]) strArray; in testSingle() local
62 array[0] = "entry zero"; in testSingle()
68 assertEquals("entry one", array[1]); in testSingle()
70 assertEquals(2, array.length); in testSingle()
[all …]

123456789