Home
last modified time | relevance | path

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

1234567

/libcore/luni/src/main/java/java/lang/reflect/
DArray.java50 private static RuntimeException badArray(Object array) { in badArray() argument
51 if (array == null) { in badArray()
53 } else if (!array.getClass().isArray()) { in badArray()
54 throw notAnArray(array); in badArray()
56 throw incompatibleType(array); in badArray()
70 …public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOf… in get() argument
71 if (array instanceof Object[]) { in get()
72 return ((Object[]) array)[index]; in get()
74 if (array instanceof boolean[]) { in get()
75 return ((boolean[]) array)[index] ? Boolean.TRUE : Boolean.FALSE; in get()
[all …]
/libcore/json/src/test/java/org/json/
DJSONArrayTest.java31 JSONArray array = new JSONArray(); in testEmptyArray() local
32 assertEquals(0, array.length()); in testEmptyArray()
33 assertEquals("", array.join(" AND ")); in testEmptyArray()
35 array.get(0); in testEmptyArray()
40 array.getBoolean(0); in testEmptyArray()
45 assertEquals("[]", array.toString()); in testEmptyArray()
46 assertEquals("[]", array.toString(4)); in testEmptyArray()
49 assertTrue(array.isNull(0)); in testEmptyArray()
50 assertNull(array.opt(0)); in testEmptyArray()
51 assertFalse(array.optBoolean(0)); in testEmptyArray()
[all …]
DParsingTest.java150 assertParsed(array(), "[]"); in testParsingArrays()
151 assertParsed(array(5, 6, true), "[5,6,true]"); in testParsingArrays()
152 assertParsed(array(5, 6, array()), "[5,6,[]]"); in testParsingArrays()
153 assertParsed(array(5, 6, 7), "[5;6;7]"); in testParsingArrays()
154 assertParsed(array(5, 6, 7), "[5 , 6 \t; \r\n 7\n]"); in testParsingArrays()
155 assertParsed(array(5, 6, 7, null), "[5,6,7,]"); in testParsingArrays()
156 assertParsed(array(null, null), "[,]"); in testParsingArrays()
157 assertParsed(array(5, null, null, null, 5), "[5,,,,5]"); in testParsingArrays()
158 assertParsed(array(null, 5), "[,5]"); in testParsingArrays()
159 assertParsed(array(null, null, null), "[,,]"); in testParsingArrays()
[all …]
DSelfUseTest.java77 private final JSONArray array = new JSONArray() { field in SelfUseTest
161 array.put("foo"); in testToJSONArray()
162 array.put("baz"); in testToJSONArray()
163 array.put("bar"); in testToJSONArray()
164 object.toJSONArray(array); in testToJSONArray()
172 array.put(10, false); in testPutAtIndex()
177 array.isNull(5); in testIsNull()
182 array.put(true); in testArrayGetType()
183 array.getBoolean(0); in testArrayGetType()
188 array.optBoolean(3); in testArrayOptType()
[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/luni/src/main/java/java/util/
DArrays.java154 public static <T> List<T> asList(T... array) { in asList() argument
155 return new ArrayList<T>(array); in asList()
168 public static int binarySearch(byte[] array, byte value) { in binarySearch() argument
169 return binarySearch(array, 0, array.length, value); in binarySearch()
188 public static int binarySearch(byte[] array, int startIndex, int endIndex, byte value) { in binarySearch() argument
189 checkBinarySearchBounds(startIndex, endIndex, array.length); in binarySearch()
195 byte midVal = array[mid]; in binarySearch()
218 public static int binarySearch(char[] array, char value) { in binarySearch() argument
219 return binarySearch(array, 0, array.length, value); in binarySearch()
238 public static int binarySearch(char[] array, int startIndex, int endIndex, char value) { in binarySearch() argument
[all …]
DUnsafeArrayList.java28 private T[] array; field in UnsafeArrayList
32 this.array = (T[]) Array.newInstance(elementType, initialCapacity); in UnsafeArrayList()
37 if (size == array.length) { in add()
39 System.arraycopy(array, 0, newArray, 0, size); in add()
40 array = newArray; in add()
42 array[size++] = element; in add()
47 public T[] array() { in array() method in UnsafeArrayList
48 return array; in array()
52 return array[i]; in get()
DArrayList.java62 transient Object[] array; field in ArrayList
75 array = (capacity == 0 ? EmptyArray.OBJECT : new Object[capacity]); in ArrayList()
82 array = EmptyArray.OBJECT; in ArrayList()
103 array = a; in ArrayList()
115 Object[] a = array; in add()
122 array = a = newArray; in add()
144 Object[] a = array; in add()
157 array = a = newArray; in add()
193 Object[] a = array; in addAll()
200 array = a = newArray; in addAll()
[all …]
/libcore/benchmarks/src/benchmarks/
DDeepArrayOpsBenchmark.java29 private Object[] array; field in DeepArrayOpsBenchmark
36 array = new Object[arrayLength * 13]; in setUp()
39 array[i] = new IntWrapper(i); in setUp()
42 array[i + 1] = new16ElementObjectarray(); in setUp()
45 array[i + 2] = new boolean[16]; in setUp()
48 array[i + 3] = new byte[16]; in setUp()
51 array[i + 4] = new char[16]; in setUp()
54 array[i + 5] = new short[16]; in setUp()
57 array[i + 6] = new float[16]; in setUp()
60 array[i + 7] = new long[16]; in setUp()
[all …]
/libcore/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/
DPriorityQueueTest.java42 Integer[] array = { 2, 45, 7, -12, 9 }; in test_iterator() local
43 for (int i = 0; i < array.length; i++) { in test_iterator()
44 integerQueue.offer(array[i]); in test_iterator()
53 Arrays.sort(array); in test_iterator()
55 assertTrue(Arrays.equals(array, resultArray)); in test_iterator()
111 Integer[] array = { 2, 45, 7, -12, 9 }; in test_iterator_remove() local
112 for (int i = 0; i < array.length; i++) { in test_iterator_remove()
113 integerQueue.offer(array[i]); in test_iterator_remove()
117 for (int i = 0; i < array.length; i++) { in test_iterator_remove()
123 assertEquals(array.length - 1, integerQueue.size()); in test_iterator_remove()
[all …]
/libcore/luni/src/main/java/java/util/concurrent/
DPriorityBlockingQueue.java249 private void tryGrow(Object[] array, int oldCap) { in tryGrow() argument
265 if (newCap > oldCap && queue == array) in tryGrow()
274 if (newArray != null && queue == array) { in tryGrow()
276 System.arraycopy(array, 0, newArray, 0, oldCap); in tryGrow()
288 Object[] array = queue; in dequeue() local
289 E result = (E) array[0]; in dequeue()
290 E x = (E) array[n]; in dequeue()
291 array[n] = null; in dequeue()
294 siftDownComparable(0, x, array, n); in dequeue()
296 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 …]
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 …]
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 …]
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 …]
DWrappedIntBufferTest.java39 int array[] = new int[20]; in testWrappedIntBuffer_IllegalArg() local
41 IntBuffer.wrap(array, -1, 0); in testWrappedIntBuffer_IllegalArg()
47 IntBuffer.wrap(array, 21, 0); in testWrappedIntBuffer_IllegalArg()
53 IntBuffer.wrap(array, 0, -1); in testWrappedIntBuffer_IllegalArg()
59 IntBuffer.wrap(array, 0, 21); in testWrappedIntBuffer_IllegalArg()
65 IntBuffer.wrap(array, Integer.MAX_VALUE, 1); in testWrappedIntBuffer_IllegalArg()
71 IntBuffer.wrap(array, 1, Integer.MAX_VALUE); in testWrappedIntBuffer_IllegalArg()
82 IntBuffer buf = IntBuffer.wrap(array, 2, 16); in testWrappedIntBuffer_IllegalArg()
DWrappedFloatBufferTest.java39 float array[] = new float[20]; in testWrappedFloatBuffer_IllegalArg() local
41 FloatBuffer.wrap(array, -1, 0); in testWrappedFloatBuffer_IllegalArg()
47 FloatBuffer.wrap(array, 21, 0); in testWrappedFloatBuffer_IllegalArg()
53 FloatBuffer.wrap(array, 0, -1); in testWrappedFloatBuffer_IllegalArg()
59 FloatBuffer.wrap(array, 0, 21); in testWrappedFloatBuffer_IllegalArg()
65 FloatBuffer.wrap(array, Integer.MAX_VALUE, 1); in testWrappedFloatBuffer_IllegalArg()
71 FloatBuffer.wrap(array, 1, Integer.MAX_VALUE); in testWrappedFloatBuffer_IllegalArg()
82 FloatBuffer buf = FloatBuffer.wrap(array, 2, 16); in testWrappedFloatBuffer_IllegalArg()
DWrappedShortBufferTest.java39 short array[] = new short[20]; in testWrappedShortBuffer_IllegalArg() local
41 ShortBuffer.wrap(array, -1, 0); in testWrappedShortBuffer_IllegalArg()
47 ShortBuffer.wrap(array, 21, 0); in testWrappedShortBuffer_IllegalArg()
53 ShortBuffer.wrap(array, 0, -1); in testWrappedShortBuffer_IllegalArg()
59 ShortBuffer.wrap(array, 0, 21); in testWrappedShortBuffer_IllegalArg()
65 ShortBuffer.wrap(array, Integer.MAX_VALUE, 1); in testWrappedShortBuffer_IllegalArg()
71 ShortBuffer.wrap(array, 1, Integer.MAX_VALUE); in testWrappedShortBuffer_IllegalArg()
82 ShortBuffer buf = ShortBuffer.wrap(array, 2, 16); in testWrappedShortBuffer_IllegalArg()
DWrappedDoubleBufferTest.java39 double array[] = new double[20]; in testWrappedDoubleuffer_IllegalArg() local
41 DoubleBuffer.wrap(array, -1, 0); in testWrappedDoubleuffer_IllegalArg()
47 DoubleBuffer.wrap(array, 21, 0); in testWrappedDoubleuffer_IllegalArg()
53 DoubleBuffer.wrap(array, 0, -1); in testWrappedDoubleuffer_IllegalArg()
59 DoubleBuffer.wrap(array, 0, 21); in testWrappedDoubleuffer_IllegalArg()
65 DoubleBuffer.wrap(array, Integer.MAX_VALUE, 1); in testWrappedDoubleuffer_IllegalArg()
71 DoubleBuffer.wrap(array, 1, Integer.MAX_VALUE); in testWrappedDoubleuffer_IllegalArg()
82 DoubleBuffer buf = DoubleBuffer.wrap(array, 2, 16); in testWrappedDoubleuffer_IllegalArg()
DWrappedLongBufferTest.java39 long array[] = new long[20]; in testWrappedLongBuffer_IllegalArg() local
41 LongBuffer.wrap(array, -1, 0); in testWrappedLongBuffer_IllegalArg()
47 LongBuffer.wrap(array, 21, 0); in testWrappedLongBuffer_IllegalArg()
53 LongBuffer.wrap(array, 0, -1); in testWrappedLongBuffer_IllegalArg()
59 LongBuffer.wrap(array, 0, 21); in testWrappedLongBuffer_IllegalArg()
65 LongBuffer.wrap(array, Integer.MAX_VALUE, 1); in testWrappedLongBuffer_IllegalArg()
71 LongBuffer.wrap(array, 1, Integer.MAX_VALUE); in testWrappedLongBuffer_IllegalArg()
82 LongBuffer buf = LongBuffer.wrap(array, 2, 16); in testWrappedLongBuffer_IllegalArg()
/libcore/luni/src/test/java/dalvik/system/
DVMRuntimeTest.java30 Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, -1); in doTestNewNonMovableArray() local
36 … Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, Integer.MIN_VALUE); in doTestNewNonMovableArray() local
43 Object array = VMRuntime.getRuntime().newNonMovableArray(componentType, i); in doTestNewNonMovableArray() local
44 assertTrue(array.getClass().isArray()); in doTestNewNonMovableArray()
45 assertEquals(array.getClass().getComponentType(), componentType); in doTestNewNonMovableArray()
46 assertEquals(Array.getLength(array), i); in doTestNewNonMovableArray()
53 Object array = VMRuntime.getRuntime().newNonMovableArray(null, 0); in testNewNonMovableArray() local
60 Object array = VMRuntime.getRuntime().newNonMovableArray(void.class, 0); in testNewNonMovableArray() local
84 Object array = VMRuntime.getRuntime().newUnpaddedArray(componentType, -1); in doTestNewUnpaddedArray() local
90 … Object array = VMRuntime.getRuntime().newUnpaddedArray(componentType, Integer.MIN_VALUE); in doTestNewUnpaddedArray() local
[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 …]
/libcore/luni/src/main/java/java/util/concurrent/atomic/
DAtomicLongArray.java23 private final long[] array; field in AtomicLongArray
33 if (i < 0 || i >= array.length) in checkedByteOffset()
50 array = new long[length]; in AtomicLongArray()
60 public AtomicLongArray(long[] array) { in AtomicLongArray() argument
62 this.array = array.clone(); in AtomicLongArray()
71 return array.length; in length()
85 return unsafe.getLongVolatile(array, offset); in getRaw()
95 unsafe.putLongVolatile(array, checkedByteOffset(i), newValue); in set()
106 unsafe.putOrderedLong(array, checkedByteOffset(i), newValue); in lazySet()
141 return unsafe.compareAndSwapLong(array, offset, expect, update); in compareAndSetRaw()
[all …]
DAtomicIntegerArray.java24 private final int[] array; field in AtomicIntegerArray
34 if (i < 0 || i >= array.length) in checkedByteOffset()
51 array = new int[length]; in AtomicIntegerArray()
61 public AtomicIntegerArray(int[] array) { in AtomicIntegerArray() argument
63 this.array = array.clone(); in AtomicIntegerArray()
72 return array.length; in length()
86 return unsafe.getIntVolatile(array, offset); in getRaw()
96 unsafe.putIntVolatile(array, checkedByteOffset(i), newValue); in set()
107 unsafe.putOrderedInt(array, checkedByteOffset(i), newValue); in lazySet()
142 return unsafe.compareAndSwapInt(array, offset, expect, update); in compareAndSetRaw()
[all …]

1234567