Lines Matching refs:elements

43  * Null elements are prohibited.  This class is likely to be faster than
81 * @param <E> the type of elements held in this collection
87 * The array in which the elements of the deque are stored.
94 * deque elements are always null.
96 private transient E[] elements;
120 * Allocate empty array to hold the given number of elements.
122 * @param numElements the number of elements to hold
126 // Find the best power of two to hold elements.
137 if (initialCapacity < 0) // Too many elements, must back off
138 initialCapacity >>>= 1;// Good luck allocating 2 ^ 30 elements
140 elements = (E[]) new Object[initialCapacity];
150 int n = elements.length;
151 int r = n - p; // number of elements to the right of p
156 System.arraycopy(elements, p, a, 0, r);
157 System.arraycopy(elements, 0, a, r, p);
158 elements = (E[])a;
164 * Copies the elements from our element array into the specified array,
166 * that the array is large enough to hold all elements in the deque.
172 System.arraycopy(elements, head, a, 0, size());
174 int headPortionLen = elements.length - head;
175 System.arraycopy(elements, head, a, 0, headPortionLen);
176 System.arraycopy(elements, 0, a, headPortionLen, tail);
183 * sufficient to hold 16 elements.
186 elements = (E[]) new Object[16];
191 * sufficient to hold the specified number of elements.
200 * Constructs a deque containing the elements of the specified
206 * @param c the collection whose elements are to be placed into the deque
227 elements[head = (head - 1) & (elements.length - 1)] = e;
243 elements[tail] = e;
244 if ( (tail = (tail + 1) & (elements.length - 1)) == head)
294 E result = elements[h]; // Element is null if deque empty
297 elements[h] = null; // Must null out slot
298 head = (h + 1) & (elements.length - 1);
303 int t = (tail - 1) & (elements.length - 1);
304 E result = elements[t];
307 elements[t] = null;
316 E x = elements[head];
326 E x = elements[(tail - 1) & (elements.length - 1)];
333 return elements[head]; // elements[head] is null if deque empty
337 return elements[(tail - 1) & (elements.length - 1)];
355 int mask = elements.length - 1;
358 while ( (x = elements[i]) != null) {
383 int mask = elements.length - 1;
386 while ( (x = elements[i]) != null) {
511 assert elements[tail] == null;
512 assert head == tail ? elements[head] == null :
513 (elements[head] != null &&
514 elements[(tail - 1) & (elements.length - 1)] != null);
515 assert elements[(head - 1) & (elements.length - 1)] == null;
519 * Removes the element at the specified position in the elements array,
521 * elements backwards or forwards in the array.
526 * @return true if elements moved backwards
530 final E[] elements = this.elements;
531 final int mask = elements.length - 1;
544 System.arraycopy(elements, h, elements, h + 1, front);
546 System.arraycopy(elements, 0, elements, 1, i);
547 elements[0] = elements[mask];
548 System.arraycopy(elements, h, elements, h + 1, mask - h);
550 elements[h] = null;
555 System.arraycopy(elements, i + 1, elements, i, back);
558 System.arraycopy(elements, i + 1, elements, i, mask - i);
559 elements[mask] = elements[0];
560 System.arraycopy(elements, 1, elements, 0, t);
570 * Returns the number of elements in this deque.
572 * @return the number of elements in this deque
575 return (tail - head) & (elements.length - 1);
579 * Returns <tt>true</tt> if this deque contains no elements.
581 * @return <tt>true</tt> if this deque contains no elements
588 * Returns an iterator over the elements in this deque. The elements
590 * order that elements would be dequeued (via successive calls to
593 * @return an iterator over the elements in this deque
628 E result = elements[cursor];
634 cursor = (cursor + 1) & (elements.length - 1);
642 cursor = (cursor - 1) & (elements.length - 1);
666 cursor = (cursor - 1) & (elements.length - 1);
667 E result = elements[cursor];
678 cursor = (cursor + 1) & (elements.length - 1);
696 int mask = elements.length - 1;
699 while ( (x = elements[i]) != null) {
725 * Removes all of the elements from this deque.
734 int mask = elements.length - 1;
736 elements[i] = null;
743 * Returns an array containing all of the elements in this deque
753 * @return an array containing all of the elements in this deque
760 * Returns an array containing all of the elements in this deque in
768 * (i.e., the array has more elements than this deque), the element in
787 * @param a the array into which the elements of the deque are to
790 * @return an array containing all of the elements in this deque
817 result.elements = Arrays.copyOf(elements, elements.length);
834 * followed by all of its elements (each an object reference) in
843 // Write out elements in order.
844 int mask = elements.length - 1;
846 s.writeObject(elements[i]);
862 // Read in all elements in the proper order.
864 elements[i] = (E)s.readObject();