From 6cf08df9921c3fadd0d853a7a8044bf033409d0c Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 16 May 2002 20:53:54 +0000 Subject: [PATCH] Implemented clone. git-svn-id: https://samskivert.googlecode.com/svn/trunk@743 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayIntSet.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java index a5398ce4..cc1c0229 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayIntSet.java @@ -1,5 +1,5 @@ // -// $Id: ArrayIntSet.java,v 1.5 2002/05/16 20:50:31 mdb Exp $ +// $Id: ArrayIntSet.java,v 1.6 2002/05/16 20:53:54 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -31,7 +31,7 @@ import java.util.NoSuchElementException; * integers to maintain the contents of the set. */ public class ArrayIntSet extends AbstractSet - implements IntSet + implements IntSet, Cloneable { // documentation inherited from interface public int size () @@ -299,6 +299,20 @@ public class ArrayIntSet extends AbstractSet return hashCode; } + // documentation inherited from interface + public Object clone () + { + try { + ArrayIntSet nset = (ArrayIntSet)super.clone(); + nset._values = new int[_values.length]; + System.arraycopy(_values, 0, nset._values, 0, _size); + return nset; + + } catch (CloneNotSupportedException cnse) { + throw new RuntimeException("Internal clone error."); + } + } + /** * Returns a string representation of this instance. */