X-Git-Url: http://git.megacz.com/?p=org.ibex.util.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Futil%2FVec.java;h=2c55c6e507fc49d1c897197e6625c57e6b321a93;hp=ffe7cfd592a577e943caace0a6ab5b68f5f08184;hb=1f80106afa0f0eb6f12544c75304f2084aca6499;hpb=3a85dab61cef1346315ca40d3004f8772815127f diff --git a/src/org/ibex/util/Vec.java b/src/org/ibex/util/Vec.java index ffe7cfd..2c55c6e 100644 --- a/src/org/ibex/util/Vec.java +++ b/src/org/ibex/util/Vec.java @@ -1,9 +1,6 @@ -// Copyright (C) 2003 Adam Megacz all rights reserved. -// -// You may modify, copy, and redistribute this code under the terms of -// the GNU Library Public License version 2.1, with the exception of -// the portion of clause 6a after the semicolon (aka the "obnoxious -// relink clause") +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. package org.ibex.util; import java.io.*; @@ -17,7 +14,7 @@ import java.io.*; * * @see java.util.Vector */ -public final class Vec implements Serializable { +public final class Vec implements Serializable, Cloneable { private Object[] store; private int size = 0; @@ -25,7 +22,13 @@ public final class Vec implements Serializable { public Vec() { this(10); } public Vec(int i) { store = new Object[i]; } public Vec(int i, Object[] store) { size = i; this.store = store; } - + public Vec(Vec old) { + store = new Object[old.store.length]; + System.arraycopy(old.store, 0, store, 0, old.store.length); + this.size = old.size; + } + + public Object clone() { return new Vec(this); } private void grow() { grow(store.length * 2); } private void grow(int newsize) { Object[] newstore = new Object[newsize]; @@ -71,7 +74,7 @@ public final class Vec implements Serializable { public void push(Object o) { addElement(o); } public Object pop() { Object ret = lastElement(); - if (size > 0) store[size--] = null; + if (size > 0) store[--size] = null; return ret; } @@ -86,9 +89,10 @@ public final class Vec implements Serializable { size = newSize; } - public void copyInto(Object[] out) { + public Object[] copyInto(Object[] out) { for(int i=0; i