@@ -37,10 +37,10 @@ private JArray()
37
37
* element to be inserted is equal to the empty element, as this could cause
38
38
* holes in the array.
39
39
* <p>
40
- * This method ensures that the array is " complete" both before and after the
41
- * its execution. Completeness is defined by the array in question having all
42
- * instances of the empty element placed only at its trailing end. Refer also
43
- * to {@link #isComplete(Object[], Object)}.
40
+ * This method ensures that the receiving array is complete both before and
41
+ * after its execution. Completeness is defined by the array in question
42
+ * having all instances of the empty element placed only at its trailing end.
43
+ * Refer also to {@link #isComplete(Object[], Object) isComplete }.
44
44
*
45
45
* @param arr the array inserted into; the receiving array
46
46
* @param emptyElem the element representing "nothing" in the array
@@ -51,8 +51,7 @@ private JArray()
51
51
* @throws ArrayStoreException if the receiving array is already full, or if
52
52
* the element to be inserted is equal to the empty element
53
53
* @throws IllegalArgumentException if the receiving array is empty
54
- * @throws IncompleteArrayException if the receiving array is not "complete,"
55
- * due to having one or more "holes" in it
54
+ * @throws IncompleteArrayException if the receiving array is not complete
56
55
* @throws NullPointerException if the receiving array is a null reference
57
56
*
58
57
* @see #isComplete(Object[], Object)
@@ -64,13 +63,15 @@ public static final <T> void insert(T[] arr, T emptyElem, int index, T newElem)
64
63
65
64
/**
66
65
* <p>
67
- * Inserts one or more elements into the array provided, moving subsequent
66
+ * Inserts zero or more elements into the array provided, moving subsequent
68
67
* elements out of the way to make room. The index provided signifies the
69
68
* point at which the first element in the varargs-array will be inserted;
70
69
* subsequent elements will be placed in the following spaces. The "empty
71
70
* element" is the element used in the array to represent an empty spot - this
72
71
* is often simply {@code null}, but can also be a pseudo-empty element if
73
- * {@code null} is to be considered a valid element.
72
+ * {@code null} is to be considered a valid element. If the array of inserted
73
+ * elements is of zero length, this method will return without modification
74
+ * nor error.
74
75
* <p>
75
76
* This method will not reallocate the array if there is insufficient space to
76
77
* store the new elements in it; the user must check its capacity prior to
@@ -79,23 +80,22 @@ public static final <T> void insert(T[] arr, T emptyElem, int index, T newElem)
79
80
* include one or more instances of the empty element, as this could create
80
81
* holes in the array.
81
82
* <p>
82
- * This method ensures that the array is " complete" both before and after the
83
- * its execution. Completeness is defined by the array in question having all
84
- * instances of the empty element placed only at its trailing end. Refer also
85
- * to {@link #isComplete(Object[], Object)}.
83
+ * This method ensures that the receiving array is complete both before and
84
+ * after its execution. Completeness is defined by the array in question
85
+ * having all instances of the empty element placed only at its trailing end.
86
+ * Refer also to {@link #isComplete(Object[], Object) isComplete }.
86
87
*
87
88
* @param arr the array inserted into; the receiving array
88
89
* @param emptyElem the element representing "nothing" in the array
89
90
* @param index the index where the first element will be inserted
90
- * @param newElems one or more elements to collectively insert into the array
91
+ * @param newElems zero or more elements to collectively insert into the array
91
92
* @throws ArrayIndexOutOfBoundsException if the index is less than zero or is
92
93
* greater than the index of the first empty element in the receiving array
93
94
* @throws ArrayStoreException if the receiving array has insufficient space
94
95
* to store the new elements, or if one or more of the elements to be inserted
95
96
* is equal to the empty element
96
97
* @throws IllegalArgumentException if the receiving array is empty
97
- * @throws IncompleteArrayException if the receiving array is not "complete,"
98
- * due to having one or more "holes" in it
98
+ * @throws IncompleteArrayException if the receiving array is not complete
99
99
* @throws NullPointerException if the receiving array or the array of new
100
100
* elements is a null reference
101
101
*
@@ -131,27 +131,26 @@ else if(contains(newElems, emptyElem))
131
131
132
132
/**
133
133
* <p>
134
- * Removes the element at the given index of the provided array, shifting
134
+ * Removes the element at the given index from the provided array, shifting
135
135
* subsequent elements into the gap. This method then also returns the element
136
136
* removed. The "empty element" is the element used in the array to represent
137
137
* an empty spot - this is often simply {@code null}, but can also be a
138
138
* pseudo-empty element if {@code null} is to be considered a valid element.
139
139
* <p>
140
- * This method ensures that the array is " complete" both before and after the
141
- * its execution. Completeness is defined by the array in question having all
140
+ * This method ensures that the array is complete both before and after its
141
+ * execution. Completeness is defined by the array in question having all
142
142
* instances of the empty element placed only at its trailing end. Refer also
143
- * to {@link #isComplete(Object[], Object)}.
143
+ * to {@link #isComplete(Object[], Object) isComplete }.
144
144
*
145
- * @param arr the array from which remove an element
145
+ * @param arr the array from which to remove an element
146
146
* @param emptyElem the element representing "nothing" in the array
147
147
* @param index the index of the element to be removed
148
148
* @return the removed element
149
149
* @throws ArrayIndexOutOfBoundsException if {@code index} is negative, or is
150
150
* greater than the index of the first empty element - or the array's length,
151
151
* if there is none
152
152
* @throws IllegalArgumentException if the array provided is empty
153
- * @throws IncompleteArrayException if the array removed from is not
154
- * "complete", due to having one or more "holes" in it
153
+ * @throws IncompleteArrayException if the array removed from is not complete
155
154
* @throws NullPointerException if the array provided is a null reference
156
155
*
157
156
* @see #isComplete(Object[], Object)
@@ -166,19 +165,19 @@ public static final <T> T remove(T[] arr, T emptyElem, int index)
166
165
* Removes all elements from {@code fromIndex}, inclusive, to {@code toIndex},
167
166
* exclusive, shifting subsequent elements into the gap. This method then also
168
167
* returns an array containing the removed elements, in the order in which
169
- * they previously occurred . The "empty element" is the element used in the
170
- * array to represent an empty spot - this is often simply {@code null}, but
171
- * can also be a pseudo-empty element if {@code null} is to be considered a
172
- * valid element.
168
+ * they were previously found in the removal array . The "empty element" is the
169
+ * element used in the array to represent an empty spot - this is often simply
170
+ * {@code null}, but can also be a pseudo-empty element if {@code null} is to
171
+ * be considered a valid element.
173
172
* <p>
174
173
* If {@code fromIndex} and {@code toIndex} are equal, the single element at
175
174
* this shared index will be removed and returned (in other words, the lower
176
175
* bound's closed-ness will take precedence).
177
176
* <p>
178
- * This method ensures that the array is " complete" both before and after the
179
- * its execution. Completeness is defined by the array in question having all
177
+ * This method ensures that the array is complete both before and after its
178
+ * execution. Completeness is defined by the array in question having all
180
179
* instances of the empty element placed only at its trailing end. Refer also
181
- * to {@link #isComplete(Object[], Object)}.
180
+ * to {@link #isComplete(Object[], Object) isComplete }.
182
181
*
183
182
* @param arr the array from which to remove one or more elements
184
183
* @param emptyElem the element representing "nothing" in the array
@@ -188,11 +187,10 @@ public static final <T> T remove(T[] arr, T emptyElem, int index)
188
187
* @throws ArrayIndexOutOfBoundsException if either {@code fromIndex} or
189
188
* {@code toIndex} is negative; if {@code fromIndex} is greater than or equal
190
189
* to the index of the first empty element; or if {@code toIndex} is strictly
191
- * greater than that same index
190
+ * greater than that same empty- index
192
191
* @throws IllegalArgumentException if the array provided is empty, or if
193
192
* {@code fromIndex > toIndex}
194
- * @throws IncompleteArrayException if the array removed from is not
195
- * "complete", due to having one or more "holes" in it
193
+ * @throws IncompleteArrayException if the array removed from is not complete
196
194
* @throws NullPointerException if the array provided is a null reference
197
195
*
198
196
* @see #isComplete(Object[], Object)
@@ -250,6 +248,17 @@ else if(fromIndex > toIndex)
250
248
* would be the value {@code null}. This could alternatively be taken as
251
249
* saying that the complete array has no holes in its midst. An empty array is
252
250
* considered as complete.
251
+ * <p>
252
+ * Examples of complete arrays:<br />
253
+ * ["one", "two", "three", "four", "five"]<br />
254
+ * ["one", "two", "three", null, null]<br />
255
+ * [null, null, null, null, null]<br />
256
+ * [ ]
257
+ * <p>
258
+ * Example of incomplete arrays:<br />
259
+ * ["one", null, "three", "four", "five"]<br />
260
+ * ["one", null, "three", "four", null]<br />
261
+ * [null, "two", "three", "four", "five"]
253
262
*
254
263
* @param arr the array checked for completeness
255
264
* @param emptyElem the element representing "nothing" in the array
0 commit comments