FileDocCategorySizeDatePackage
NonSynchronizedVector.javaAPI DocGlassfish v2 API13707Tue May 22 16:54:34 BST 2007oracle.toplink.essentials.internal.helper

NonSynchronizedVector

public class NonSynchronizedVector extends Vector
Vector subclass that removes the synchronization.

Fields Summary
Constructors Summary
public NonSynchronizedVector(int initialCapacity, int capacityIncrement)

        super(initialCapacity, capacityIncrement);
    
public NonSynchronizedVector(int initialCapacity)

        super(initialCapacity);
    
public NonSynchronizedVector()

        super();
    
public NonSynchronizedVector(Collection c)

        super(c);
    
Methods Summary
public booleanadd(java.lang.Object o)

        modCount++;
        ensureCapacityHelper(elementCount + 1);
        elementData[elementCount++] = o;
        return true;
    
public booleanaddAll(java.util.Collection c)

        modCount++;
            Object[] a = c.toArray();
            int numNew = a.length;
        ensureCapacityHelper(elementCount + numNew);
            System.arraycopy(a, 0, elementData, elementCount, numNew);
            elementCount += numNew;
        return numNew != 0;
    
public booleanaddAll(int index, java.util.Collection c)

        modCount++;
        if (index < 0 || index > elementCount)
            throw new ArrayIndexOutOfBoundsException(index);
    
            Object[] a = c.toArray();
        int numNew = a.length;
        ensureCapacityHelper(elementCount + numNew);
    
        int numMoved = elementCount - index;
        if (numMoved > 0)
            System.arraycopy(elementData, index, elementData, index + numNew,
                     numMoved);
    
            System.arraycopy(a, 0, elementData, index, numNew);
        elementCount += numNew;
        return numNew != 0;
    
public voidaddElement(java.lang.Object obj)

        modCount++;
        ensureCapacityHelper(elementCount + 1);
        elementData[elementCount++] = obj;
    
public intcapacity()

        return elementData.length;
    
public booleancontainsAll(java.util.Collection c)

        Iterator e = c.iterator();
        while (e.hasNext())
            if(!contains(e.next()))
                return false;
    
        return true;
    
public voidcopyInto(java.lang.Object[] anArray)

        System.arraycopy(elementData, 0, anArray, 0, elementCount);
    
public java.lang.ObjectelementAt(int index)

        if (index >= elementCount) {
            throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount);
        }
        return elementData[index];
    
public java.util.Enumerationelements()

        return new Enumeration() {
            int count = 0;
    
            public boolean hasMoreElements() {
                return count < elementCount;
            }
    
            public Object nextElement() {
                if (count < elementCount) {
                    return elementData[count++];
                }
                throw new NoSuchElementException("Vector Enumeration");
            }
        };
    
public voidensureCapacity(int minCapacity)

        modCount++;
        ensureCapacityHelper(minCapacity);
    
private voidensureCapacityHelper(int minCapacity)

        int oldCapacity = elementData.length;
        if (minCapacity > oldCapacity) {
            Object oldData[] = elementData;
            int newCapacity = (capacityIncrement > 0) ?
            (oldCapacity + capacityIncrement) : (oldCapacity * 2);
            if (newCapacity < minCapacity) {
                newCapacity = minCapacity;
            }
            elementData = new Object[newCapacity];
            System.arraycopy(oldData, 0, elementData, 0, elementCount);
        }
    
public booleanequals(java.lang.Object o)

        if (o == this)
            return true;
        if (!(o instanceof List))
            return false;
    
        ListIterator e1 = listIterator();
        ListIterator e2 = ((List) o).listIterator();
        while(e1.hasNext() && e2.hasNext()) {
            Object o1 = e1.next();
            Object o2 = e2.next();
            if (!(o1==null ? o2==null : o1.equals(o2)))
            return false;
        }
        return !(e1.hasNext() || e2.hasNext());
    
public java.lang.ObjectfirstElement()

        if (elementCount == 0) {
            throw new NoSuchElementException();
        }
        return elementData[0];
    
public java.lang.Objectget(int index)

        if (index >= elementCount)
            throw new ArrayIndexOutOfBoundsException(index);

        return elementData[index];
    
public inthashCode()

        int hashCode = 1;
        Iterator i = iterator();
            while (i.hasNext()) {
            Object obj = i.next();
            hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
        }
        return hashCode;
    
public intindexOf(java.lang.Object elem, int index)

        if (elem == null) {
            for (int i = index ; i < elementCount ; i++)
            if (elementData[i]==null)
                return i;
        } else {
            for (int i = index ; i < elementCount ; i++)
            if (elem.equals(elementData[i]))
                return i;
        }
        return -1;
    
public voidinsertElementAt(java.lang.Object obj, int index)

        modCount++;
        if (index > elementCount) {
            throw new ArrayIndexOutOfBoundsException(index
                                 + " > " + elementCount);
        }
        ensureCapacityHelper(elementCount + 1);
        System.arraycopy(elementData, index, elementData, index + 1, elementCount - index);
        elementData[index] = obj;
        elementCount++;
    
public booleanisEmpty()

        return elementCount == 0;
    
public java.lang.ObjectlastElement()

        if (elementCount == 0) {
            throw new NoSuchElementException();
        }
        return elementData[elementCount - 1];
    
public intlastIndexOf(java.lang.Object elem)

        return lastIndexOf(elem, elementCount-1);
    
public intlastIndexOf(java.lang.Object elem, int index)

        if (index >= elementCount)
            throw new IndexOutOfBoundsException(index + " >= "+ elementCount);
        if (elem == null) {
            for (int i = index; i >= 0; i--)
            if (elementData[i]==null)
                return i;
        } else {
            for (int i = index; i >= 0; i--)
            if (elem.equals(elementData[i]))
                return i;
        }
        return -1;
    
public static oracle.toplink.essentials.internal.helper.NonSynchronizedVectornewInstance(int initialCapacity, int capacityIncrement)

        return new NonSynchronizedVector(initialCapacity, capacityIncrement);
    
public static oracle.toplink.essentials.internal.helper.NonSynchronizedVectornewInstance(int initialCapacity)

        return new NonSynchronizedVector(initialCapacity);
    
public static oracle.toplink.essentials.internal.helper.NonSynchronizedVectornewInstance()

        return new NonSynchronizedVector();
    
public static oracle.toplink.essentials.internal.helper.NonSynchronizedVectornewInstance(java.util.Collection c)

        return new NonSynchronizedVector(c);
    
public java.lang.Objectremove(int index)

        modCount++;
        if (index >= elementCount)
            throw new ArrayIndexOutOfBoundsException(index);
        Object oldValue = elementData[index];
    
        int numMoved = elementCount - index - 1;
        if (numMoved > 0)
            System.arraycopy(elementData, index+1, elementData, index,
                     numMoved);
        elementData[--elementCount] = null; // Let gc do its work
    
        return oldValue;
    
public booleanremoveAll(java.util.Collection c)

        boolean modified = false;
        Iterator e = iterator();
        while (e.hasNext()) {
            if(c.contains(e.next())) {
            e.remove();
            modified = true;
            }
        }
        return modified;
    
public voidremoveAllElements()

        modCount++;
        // Let gc do its work
        for (int i = 0; i < elementCount; i++)
            elementData[i] = null;
    
        elementCount = 0;
    
public booleanremoveElement(java.lang.Object obj)

        modCount++;
        int i = indexOf(obj);
        if (i >= 0) {
            removeElementAt(i);
            return true;
        }
        return false;
    
public voidremoveElementAt(int index)

        modCount++;
        if (index >= elementCount) {
            throw new ArrayIndexOutOfBoundsException(index + " >= " + 
                                 elementCount);
        } else if (index < 0) {
            throw new ArrayIndexOutOfBoundsException(index);
        }
        int j = elementCount - index - 1;
        if (j > 0) {
            System.arraycopy(elementData, index + 1, elementData, index, j);
        }
        elementCount--;
        elementData[elementCount] = null; /* to let gc do its work */
    
protected voidremoveRange(int fromIndex, int toIndex)

        modCount++;
        int numMoved = elementCount - toIndex;
            System.arraycopy(elementData, toIndex, elementData, fromIndex,
                             numMoved);
    
        // Let gc do its work
        int newElementCount = elementCount - (toIndex-fromIndex);
        while (elementCount != newElementCount)
            elementData[--elementCount] = null;
    
public booleanretainAll(java.util.Collection c)

        boolean modified = false;
        Iterator e = iterator();
        while (e.hasNext()) {
            if(!c.contains(e.next())) {
            e.remove();
            modified = true;
            }
        }
        return modified;
    
public java.lang.Objectset(int index, java.lang.Object element)

        if (index >= elementCount)
            throw new ArrayIndexOutOfBoundsException(index);
    
        Object oldValue = elementData[index];
        elementData[index] = element;
        return oldValue;
    
public voidsetElementAt(java.lang.Object obj, int index)

        if (index >= elementCount) {
            throw new ArrayIndexOutOfBoundsException(index + " >= " + 
                                 elementCount);
        }
        elementData[index] = obj;
    
public voidsetSize(int newSize)

        modCount++;
        if (newSize > elementCount) {
            ensureCapacityHelper(newSize);
        } else {
            for (int i = newSize ; i < elementCount ; i++) {
            elementData[i] = null;
            }
        }
        elementCount = newSize;
    
public intsize()

        return elementCount;
    
public java.lang.Object[]toArray()

        Object[] result = new Object[elementCount];
        System.arraycopy(elementData, 0, result, 0, elementCount);
        return result;
    
public java.lang.Object[]toArray(java.lang.Object[] a)

        if (a.length < elementCount)
            a = (Object[])java.lang.reflect.Array.newInstance(
                                a.getClass().getComponentType(), elementCount);

        System.arraycopy(elementData, 0, a, 0, elementCount);

        if (a.length > elementCount)
            a[elementCount] = null;

        return a;
    
public java.lang.StringtoString()

        StringBuffer buf = new StringBuffer();
        Iterator e = iterator();
        buf.append("[");
        int maxIndex = size() - 1;
        for (int i = 0; i <= maxIndex; i++) {
            buf.append(String.valueOf(e.next()));
            if (i < maxIndex)
            buf.append(", ");
        }
        buf.append("]");
        return buf.toString();
    
public voidtrimToSize()

        modCount++;
        int oldCapacity = elementData.length;
        if (elementCount < oldCapacity) {
            Object oldData[] = elementData;
            elementData = new Object[elementCount];
            System.arraycopy(oldData, 0, elementData, 0, elementCount);
        }
    
private voidwriteObject(java.io.ObjectOutputStream s)

        s.defaultWriteObject();