From 1eaca557724c3c7a37e3ed3becee140782b770fe Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 10 Apr 2009 08:52:48 +0000 Subject: [PATCH] change our vector remove method to be like java --- Robust/src/ClassLibrary/LinkedList.java | 18 ++++++++++++++---- Robust/src/ClassLibrary/Vector.java | 11 +++++------ Robust/src/Runtime/runtime.c | 8 ++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Robust/src/ClassLibrary/LinkedList.java b/Robust/src/ClassLibrary/LinkedList.java index 98701fba..72f57dd2 100644 --- a/Robust/src/ClassLibrary/LinkedList.java +++ b/Robust/src/ClassLibrary/LinkedList.java @@ -70,11 +70,21 @@ public class LinkedList { public boolean contains( Object o ) { LinkedListElement e = head; - while( e != null ) { - if( e.element == o ) { - return true; + if (o==null) { + while(e!=null) { + if (e.element==null) { + return true; + } + e=e.next; + } + return false; + } else { + while( e != null ) { + if (o.equals(e.element)) { + return true; + } + e = e.next; } - e = e.next; } return false; } diff --git a/Robust/src/ClassLibrary/Vector.java b/Robust/src/ClassLibrary/Vector.java index 9ae2baf7..162ff824 100644 --- a/Robust/src/ClassLibrary/Vector.java +++ b/Robust/src/ClassLibrary/Vector.java @@ -56,9 +56,7 @@ public class Vector { } public void setElementAt(Object obj, int index) { - if (index>=size) - ensureCapacity(index+1); - if (index>=0 && index extern int classsize[]; extern int typearray[]; @@ -112,6 +113,13 @@ void CALL11(___System______exit____I,int ___status___, int ___status___) { exit(___status___); } +void CALL12(___Vector______removeElement_____AR_L___Object____I, int ___index___, struct ArrayObject * ___array___, int ___index___) { + int length=VAR(___array___)->___length___; + char* offset=((char *)(&VAR(___array___)->___length___))+sizeof(unsigned int)+sizeof(void *)*___index___; + memmove(offset, offset+sizeof(void *),(length-___index___-1)*sizeof(void *)); +} + + void CALL11(___System______printI____I,int ___status___, int ___status___) { printf("%d\n",___status___); } -- 2.34.1