X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/ObjectVector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/ObjectVector.java index ff75c47..f842b7c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/ObjectVector.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/util/ObjectVector.java @@ -1,23 +1,25 @@ /******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. + * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html + * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation - ******************************************************************************/ + *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.util; public final class ObjectVector { - + static int INITIAL_SIZE = 10; public int size; + int maxSize; + Object[] elements; - + public ObjectVector() { this.maxSize = INITIAL_SIZE; @@ -28,27 +30,36 @@ public final class ObjectVector { public void add(Object newElement) { if (this.size == this.maxSize) // knows that size starts <= maxSize - System.arraycopy(this.elements, 0, (this.elements = new Object[this.maxSize *= 2]), 0, this.size); + System.arraycopy(this.elements, 0, + (this.elements = new Object[this.maxSize *= 2]), 0, + this.size); this.elements[this.size++] = newElement; } public void addAll(Object[] newElements) { if (this.size + newElements.length >= this.maxSize) { - maxSize = this.size + newElements.length; // assume no more elements will be added - System.arraycopy(this.elements, 0, (this.elements = new Object[this.maxSize]), 0, this.size); + maxSize = this.size + newElements.length; // assume no more + // elements will be + // added + System.arraycopy(this.elements, 0, + (this.elements = new Object[this.maxSize]), 0, this.size); } - System.arraycopy(newElements, 0, this.elements, size, newElements.length); + System.arraycopy(newElements, 0, this.elements, size, + newElements.length); this.size += newElements.length; } public void addAll(ObjectVector newVector) { if (this.size + newVector.size >= this.maxSize) { - maxSize = this.size + newVector.size; // assume no more elements will be added - System.arraycopy(this.elements, 0, (this.elements = new Object[this.maxSize]), 0, this.size); + maxSize = this.size + newVector.size; // assume no more elements + // will be added + System.arraycopy(this.elements, 0, + (this.elements = new Object[this.maxSize]), 0, this.size); } - System.arraycopy(newVector.elements, 0, this.elements, size, newVector.size); + System.arraycopy(newVector.elements, 0, this.elements, size, + newVector.size); this.size += newVector.size; } @@ -74,16 +85,16 @@ public final class ObjectVector { return false; } - public void copyInto(Object[] targetArray){ - + public void copyInto(Object[] targetArray) { + this.copyInto(targetArray, 0); } - - public void copyInto(Object[] targetArray, int index){ - + + public void copyInto(Object[] targetArray, int index) { + System.arraycopy(this.elements, 0, targetArray, index, this.size); - } - + } + public Object elementAt(int index) { return this.elements[index]; @@ -103,7 +114,8 @@ public final class ObjectVector { for (int i = this.size; --i >= 0;) if (element.equals(this.elements[i])) { // shift the remaining elements down one spot - System.arraycopy(this.elements, i + 1, this.elements, i, --this.size - i); + System.arraycopy(this.elements, i + 1, this.elements, i, + --this.size - i); this.elements[this.size] = null; return element; } @@ -111,22 +123,22 @@ public final class ObjectVector { } public void removeAll() { - + for (int i = this.size; --i >= 0;) this.elements[i] = null; this.size = 0; } - public int size(){ - + public int size() { + return this.size; } - + public String toString() { - + String s = ""; //$NON-NLS-1$ for (int i = 0; i < this.size; i++) s += this.elements[i].toString() + "\n"; //$NON-NLS-1$ return s; } -} \ No newline at end of file +}