From 1ac50778f99c135db6d8a4243bb4ddbfcb2d45e3 Mon Sep 17 00:00:00 2001 From: ray Date: Thu, 13 Nov 2003 18:36:07 +0000 Subject: [PATCH] implements Cloneable. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1303 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/HashIntMap.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/HashIntMap.java b/projects/samskivert/src/java/com/samskivert/util/HashIntMap.java index 4f1ddfc1..395a39dc 100644 --- a/projects/samskivert/src/java/com/samskivert/util/HashIntMap.java +++ b/projects/samskivert/src/java/com/samskivert/util/HashIntMap.java @@ -1,5 +1,5 @@ // -// $Id: HashIntMap.java,v 1.12 2003/10/24 22:10:16 ray Exp $ +// $Id: HashIntMap.java,v 1.13 2003/11/13 18:36:07 ray Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -39,7 +39,7 @@ import java.util.Set; * hashtable mechanism to store its key/value mappings. */ public class HashIntMap - extends AbstractMap implements IntMap, Serializable + extends AbstractMap implements IntMap, Cloneable, Serializable { public interface Entry extends AbstractMap.Entry { @@ -386,6 +386,18 @@ public class HashIntMap return values().iterator(); } + // documentation inherited from interface cloneable + public Object clone () + { + HashIntMap copy = new HashIntMap(_buckets.length, _loadFactor); + + for (Iterator itr = new EntryIterator(); itr.hasNext(); ) { + Entry entry = (Entry) itr.next(); + copy.put(entry.getIntKey(), entry.getValue()); + } + return copy; + } + /** * Save the state of this instance to a stream (i.e., serialize it). */