[m-rev.] For review: Java implementation of array library
James Goddard
goddardjames at yahoo.com
Fri Jan 9 13:06:31 AEDT 2004
Here's the relative diff with the changes discussed:
diff -u array.m array.m
--- array.m 8 Jan 2004 06:14:42 -0000
+++ array.m 9 Jan 2004 02:03:03 -0000
@@ -988,24 +988,23 @@
java.lang.Class itemClass = Item.getClass();
if (Array0 == null) {
- Array = java.lang.reflect.Array.newInstance(itemClass, Size);
- for (int i = 0; i < Size; i++) {
- java.lang.reflect.Array.set(Array, i, Item);
+ if (Size == 0) {
+ Array = null;
+ } else {
+ Array = java.lang.reflect.Array.newInstance(
+ itemClass, Size);
+ for (int i = 0; i < Size; i++) {
+ java.lang.reflect.Array.set(Array, i, Item);
+ }
}
} else if (java.lang.reflect.Array.getLength(Array0) == Size) {
Array = Array0;
- } else if (java.lang.reflect.Array.getLength(Array0) > Size) {
- Array = java.lang.reflect.Array.newInstance(itemClass, Size);
- for (int i = 0; i < Size; i++) {
- java.lang.reflect.Array.set(Array, i,
- java.lang.reflect.Array.get(Array0, i)
- );
- }
} else {
Array = java.lang.reflect.Array.newInstance(itemClass, Size);
int i;
- for (i = 0; i < java.lang.reflect.Array.getLength(Array0); i++)
+ for (i = 0; i < java.lang.reflect.Array.getLength(Array0) &&
+ i < Size; i++)
{
java.lang.reflect.Array.set(Array, i,
java.lang.reflect.Array.get(Array0, i)
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list