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;
}
}
public void setElementAt(Object obj, int index) {
- if (index>=size)
- ensureCapacity(index+1);
- if (index>=0 && index <size)
+ if (index <size)
array[index]=obj;
else {
System.printString("Illegal Vector.setElementAt\n");
System.printString("Illegal Vector.removeElementAt\n");
System.exit(-1);
}
- for(int i=index; i<(size-1); i++) {
- array[i]=array[i+1];
- }
+ removeElement(array, index);
size--;
+ array[size]=null;
}
+ public static native void removeElement(Object[] array, int index);
+
public void removeAllElements() {
int s = size;
for(int i = 0; i<s; ++i ) {
#ifdef STM
#include "tm.h"
#endif
+#include <string.h>
extern int classsize[];
extern int typearray[];
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___);
}