Skip to content

Commit d6c7b69

Browse files
committed
Improved docs re: completeness. Less repetitive, insulting to reader's intelligence. Fewer scare-quotes.
1 parent c837876 commit d6c7b69

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
lines changed

src/net/danielhildebrandt/IncompleteArrayException.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44

55
/**
66
* <p>
7-
* Thrown whenever some method requires that an array be complete, yet the one
8-
* passed in in fact is not.
9-
* <p>
10-
* An array is "complete" if and only if the "empty-element" - the element
11-
* representing nothing within that array, <code>null</code> or otherwise -
12-
* occurs only on the trailing end of it, or not at all. Thus, a complete array
13-
* will not have "holes" in the middle.
7+
* Thrown whenever some method requires that an array be complete, but the one
8+
* provided is not.
149
*
1510
* @see JArray#isComplete(Object[], Object)
1611
*/
@@ -19,8 +14,8 @@ public final class IncompleteArrayException extends RuntimeException
1914
private static final long serialVersionUID = 1L;
2015

2116
/**
22-
* Constructs a new <code>IncompleteArrayException</code> with a message
23-
* listing the contents of the array and the empty-element.
17+
* Constructs a new {@code IncompleteArrayException} with a message listing
18+
* the contents of the array and the empty-element.
2419
* @param arr the array found to be incomplete
2520
* @param emptyElem the element representing "nothing" in the array
2621
*/

src/net/danielhildebrandt/JArray.java

+41-32
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ private JArray()
3737
* element to be inserted is equal to the empty element, as this could cause
3838
* holes in the array.
3939
* <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}.
4444
*
4545
* @param arr the array inserted into; the receiving array
4646
* @param emptyElem the element representing "nothing" in the array
@@ -51,8 +51,7 @@ private JArray()
5151
* @throws ArrayStoreException if the receiving array is already full, or if
5252
* the element to be inserted is equal to the empty element
5353
* @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
5655
* @throws NullPointerException if the receiving array is a null reference
5756
*
5857
* @see #isComplete(Object[], Object)
@@ -64,13 +63,15 @@ public static final <T> void insert(T[] arr, T emptyElem, int index, T newElem)
6463

6564
/**
6665
* <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
6867
* elements out of the way to make room. The index provided signifies the
6968
* point at which the first element in the varargs-array will be inserted;
7069
* subsequent elements will be placed in the following spaces. The "empty
7170
* element" is the element used in the array to represent an empty spot - this
7271
* 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.
7475
* <p>
7576
* This method will not reallocate the array if there is insufficient space to
7677
* 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)
7980
* include one or more instances of the empty element, as this could create
8081
* holes in the array.
8182
* <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}.
8687
*
8788
* @param arr the array inserted into; the receiving array
8889
* @param emptyElem the element representing "nothing" in the array
8990
* @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
9192
* @throws ArrayIndexOutOfBoundsException if the index is less than zero or is
9293
* greater than the index of the first empty element in the receiving array
9394
* @throws ArrayStoreException if the receiving array has insufficient space
9495
* to store the new elements, or if one or more of the elements to be inserted
9596
* is equal to the empty element
9697
* @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
9999
* @throws NullPointerException if the receiving array or the array of new
100100
* elements is a null reference
101101
*
@@ -131,27 +131,26 @@ else if(contains(newElems, emptyElem))
131131

132132
/**
133133
* <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
135135
* subsequent elements into the gap. This method then also returns the element
136136
* removed. The "empty element" is the element used in the array to represent
137137
* an empty spot - this is often simply {@code null}, but can also be a
138138
* pseudo-empty element if {@code null} is to be considered a valid element.
139139
* <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
142142
* 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}.
144144
*
145-
* @param arr the array from which remove an element
145+
* @param arr the array from which to remove an element
146146
* @param emptyElem the element representing "nothing" in the array
147147
* @param index the index of the element to be removed
148148
* @return the removed element
149149
* @throws ArrayIndexOutOfBoundsException if {@code index} is negative, or is
150150
* greater than the index of the first empty element - or the array's length,
151151
* if there is none
152152
* @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
155154
* @throws NullPointerException if the array provided is a null reference
156155
*
157156
* @see #isComplete(Object[], Object)
@@ -166,19 +165,19 @@ public static final <T> T remove(T[] arr, T emptyElem, int index)
166165
* Removes all elements from {@code fromIndex}, inclusive, to {@code toIndex},
167166
* exclusive, shifting subsequent elements into the gap. This method then also
168167
* 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.
173172
* <p>
174173
* If {@code fromIndex} and {@code toIndex} are equal, the single element at
175174
* this shared index will be removed and returned (in other words, the lower
176175
* bound's closed-ness will take precedence).
177176
* <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
180179
* 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}.
182181
*
183182
* @param arr the array from which to remove one or more elements
184183
* @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)
188187
* @throws ArrayIndexOutOfBoundsException if either {@code fromIndex} or
189188
* {@code toIndex} is negative; if {@code fromIndex} is greater than or equal
190189
* 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
192191
* @throws IllegalArgumentException if the array provided is empty, or if
193192
* {@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
196194
* @throws NullPointerException if the array provided is a null reference
197195
*
198196
* @see #isComplete(Object[], Object)
@@ -250,6 +248,17 @@ else if(fromIndex > toIndex)
250248
* would be the value {@code null}. This could alternatively be taken as
251249
* saying that the complete array has no holes in its midst. An empty array is
252250
* 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"]
253262
*
254263
* @param arr the array checked for completeness
255264
* @param emptyElem the element representing "nothing" in the array

0 commit comments

Comments
 (0)