diff options
author | David Sheldon <dave@mono-cvs.ximian.com> | 2004-03-19 02:25:35 +0300 |
---|---|---|
committer | David Sheldon <dave@mono-cvs.ximian.com> | 2004-03-19 02:25:35 +0300 |
commit | 16fcacf2300966fdc3e7a248708848345d33b55b (patch) | |
tree | 5434f5289f57239c09ef3171ab1e63f5ead44731 | |
parent | 1cd1961f745c37f8a8e730928745841ec18930ef (diff) |
2004-03-18 David Sheldon <dave-mono@earth.li>
* Hashtable.cs: Serialise/Deserialise to two arrays of
keys/values. This will match what MS.NET appears to be
doing.
svn path=/trunk/mcs/; revision=24308
-rw-r--r-- | mcs/class/corlib/System.Collections/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/class/corlib/System.Collections/Hashtable.cs | 36 |
2 files changed, 35 insertions, 7 deletions
diff --git a/mcs/class/corlib/System.Collections/ChangeLog b/mcs/class/corlib/System.Collections/ChangeLog index 63b4c2c5360..85cd13fb10b 100644 --- a/mcs/class/corlib/System.Collections/ChangeLog +++ b/mcs/class/corlib/System.Collections/ChangeLog @@ -1,3 +1,9 @@ +2004-03-18 David Sheldon <dave-mono@earth.li> + + * Hashtable.cs: Serialise/Deserialise to two arrays of + keys/values. This will match what MS.NET appears to be + doing. + 2004-02-12 Jackson Harper <jackson@ximian.com> * SortedList.cs: Only .et 1.0 sets the capacity to a min of diff --git a/mcs/class/corlib/System.Collections/Hashtable.cs b/mcs/class/corlib/System.Collections/Hashtable.cs index ac9e47b7cbb..8d27c7ebefd 100644 --- a/mcs/class/corlib/System.Collections/Hashtable.cs +++ b/mcs/class/corlib/System.Collections/Hashtable.cs @@ -187,10 +187,23 @@ namespace System.Collections { modificationCount = (int) info.GetValue ("Version", typeof(int)); comparerRef = (IComparer) info.GetValue ("Comparer", typeof (object)); hcpRef = (IHashCodeProvider) info.GetValue ("HashCodeProvider", typeof (object)); - inUse = (int) info.GetValue ("HashSize", typeof(int)); - table = (Slot[]) info.GetValue("Table", typeof(Slot[])); - threshold = (int) info.GetValue("Treshold", typeof(int)); - } + int size = (int) info.GetValue ("HashSize", typeof(int)); + Object [] keys = (Object []) info.GetValue("Keys", typeof(Object [] )); + Object [] values = (Object []) info.GetValue("Values", typeof(Object [] )); + + if (keys.Length != values.Length) + throw new SerializationException("Keys and values of uneven size"); + + size = ToPrime (size); + this.SetTable (new Slot [size]); + + for(int i=0;i<keys.Length;i++) { + Add(keys[i], values[i]); + } + + + AdjustThreshold(); + } // // Properties @@ -422,9 +435,18 @@ namespace System.Collections { info.AddValue ("Version", modificationCount); info.AddValue ("Comparer", comparerRef); info.AddValue ("HashCodeProvider", hcpRef); - info.AddValue ("HashSize", inUse); - info.AddValue ("Table", table); - info.AddValue ("Treshold", threshold); + info.AddValue ("HashSize", this.table.Length); +// Create Keys + Object [] keys = new Object[inUse]; + CopyToArray(keys, 0, EnumeratorMode.KEY_MODE); + +// Create Values + Object [] values = new Object[inUse]; + CopyToArray(values, 0, EnumeratorMode.VALUE_MODE); + + info.AddValue ("Keys", keys); + info.AddValue ("Values", values); + } public virtual void OnDeserialization (object sender) |