Mercurial > projects > dwt2
diff java/src/java/util/LinkedList.d @ 10:eb8ff453285d
Added java.util collection classes.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 13 Mar 2009 16:57:07 +0100 |
parents | |
children | 9b96950f2c3c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/java/util/LinkedList.d Fri Mar 13 16:57:07 2009 +0100 @@ -0,0 +1,231 @@ +module java.util.LinkedList; + +import java.lang.all; +import java.util.List; +import java.util.Iterator; +import java.util.ListIterator; +import java.util.Collection; + +static import tango.util.container.CircularList; + +class LinkedList : List { + alias tango.util.container.CircularList.CircularList!(Object) ListType; + private ListType list; + + this(){ + list = new ListType(); + } + this( Collection c ){ + this(); + addAll(c); + } + void add(int index, Object element){ + list.addAt(index,element); + return true; + } + bool add(Object o){ + list.add(o); + return true; + } + public bool add(String o){ + return add(stringcast(o)); + } + bool addAll(Collection c){ + if( c is null ) throw new NullPointerException(); + bool res = false; + foreach( o; c ){ + res |= add( o ); + } + return res; + } + bool addAll(int index, Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + void addFirst(Object o){ + list.prepend( o ); + } + void addLast(Object o){ + list.append( o ); + } +// void addElement(Object obj){ +// implMissing( __FILE__, __LINE__ ); +// } + int capacity(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + void clear(){ + list.clear(); + } + Object clone(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + bool contains(Object elem){ + return list.contains(elem); + } + bool contains(String elem){ + return contains(stringcast(elem)); + } + bool containsAll(Collection c){ + foreach(o; c){ + if( !list.contains(o)) return false; + } + return true; + } + void copyInto(Object[] anArray){ + implMissing( __FILE__, __LINE__ ); + } + Object elementAt(int index){ + return list.get(index); + } +// Enumeration elements(){ +// implMissing( __FILE__, __LINE__ ); +// return null; +// } + void ensureCapacity(int minCapacity){ + implMissing( __FILE__, __LINE__ ); + } + int opEquals(Object o){ + implMissing( __FILE__, __LINE__ ); + return false; + } + Object firstElement(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object get(int index){ + return list.get(index); + } + Object getFirst(){ + return list.get(0); + } + Object getLast(){ + return list.get(list.size()-1); + } + hash_t toHash(){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + int indexOf(Object elem){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + int indexOf(Object elem, int index){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + void insertElementAt(Object obj, int index){ + implMissing( __FILE__, __LINE__ ); + } + bool isEmpty(){ + return list.isEmpty(); + } + Iterator iterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object lastElement(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + int lastIndexOf(Object elem){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + int lastIndexOf(Object elem, int index){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + ListIterator listIterator(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + ListIterator listIterator(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object remove(int index){ + implMissing( __FILE__, __LINE__ ); + return null; + } + bool remove(Object o){ + return list.remove(o,false) !is 0; + } + public bool remove(String key){ + return remove(stringcast(key)); + } + bool removeAll(Collection c){ + bool res = false; + foreach( o; c){ + res |= list.remove(o,false) !is 0; + } + return res; + } + void removeAllElements(){ + implMissing( __FILE__, __LINE__ ); + } + Object removeFirst(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object removeLast(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + bool removeElement(Object obj){ + implMissing( __FILE__, __LINE__ ); + return false; + } + void removeElementAt(int index){ + implMissing( __FILE__, __LINE__ ); + } + protected void removeRange(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + } + bool retainAll(Collection c){ + implMissing( __FILE__, __LINE__ ); + return false; + } + Object set(int index, Object element){ + implMissing( __FILE__, __LINE__ ); + return null; + } + void setElementAt(Object obj, int index){ + implMissing( __FILE__, __LINE__ ); + } + void setSize(int newSize){ + implMissing( __FILE__, __LINE__ ); + } + int size(){ + return list.size(); + } + List subList(int fromIndex, int toIndex){ + implMissing( __FILE__, __LINE__ ); + return null; + } + Object[] toArray(){ + if( list.size() is 0 ) return null; // workaround tango ticket 1237 + return list.toArray(); + } + Object[] toArray(Object[] a){ + if( list.size() is 0 ) return a[0 .. 0]; // workaround tango ticket 1237 + return list.toArray( a ); + } + String toString(){ + implMissing( __FILE__, __LINE__ ); + return null; + } + void trimToSize(){ + implMissing( __FILE__, __LINE__ ); + } + + // only for D + public int opApply (int delegate(ref Object value) dg){ + implMissing( __FILE__, __LINE__ ); + return 0; + } + +} +