2010-01-24 Robert Jordan <[email protected]>
* Dictionary.cs: Fix deserialization compatibility with MS.NET.
Fixes bug #474009.
In Test/System.Collections.Generic:
2010-01-24 Robert Jordan <[email protected]>
* DictionaryTest.cs: Add test case for bug #474009.
svn path=/trunk/mcs/; revision=150089
* Dictionary.cs: Always create the keys, fixes compatibility
between Mono and .NET. Patch from John Lenz <[email protected]>
svn path=/trunk/mcs/; revision=149947
* Dictionary.cs: cast target array to TRet[] instead of object[] -
may fail, but otherwise it doesn't compile with 2.4 (e.g. when
bootstrapping trunk)
svn path=/trunk/mcs/; revision=143188
* System.Collections.Generic/Dictionary.cs (CopyToCheck, Do_CopyTo):
Carve out of ...
(CopyTo): ... this.
(Do_ICollectionCopyTo): Carve out of ICollection.CopyTo. Convert
type-cast exceptions to ArgumentExceptions.
(KeyCollection.CopyTo): Use them.
(ValueCollection.CopyTo): Use them.
* Test/System.Collections.Generic/DictionaryTest.cs (ICollectionCopyTo):
Test various odd scenarios where .NET CopyTo does _not_ throw an exception.
(ICollectionCopyTo_ex1..4): Ensure that ArgumentExceptions are
thrown in appropriate cases.
svn path=/trunk/mcs/; revision=142427
* System.Collections.Generic/Dictionary.cs (Enumerator.current): New.
(Enumerator.MoveNext): Update it.
(Enumerator.Current): Don't verify any invariants.
* Test/System.Collections.Generic/DictionaryTest.cs (Enumerator_Current):
New test, includes relevant parts of #491858 and #517415.
svn path=/trunk/mcs/; revision=139082
* Dictionary.cs (ValueCollection.CopyTo): fix for copying to
an object array. Based on a patch by Tobias Grimm <[email protected]>.
Fixes bug #328036.
svn path=/trunk/mcs/; revision=130884
* Dictionary.cs: Declare the Link struct outside the main class to avoid
creating a separate inflated instances for each instantiation of Dictionary.
svn path=/trunk/mcs/; revision=125739
* Dictionary.cs (ICollection.CopyTo): fix the different possible
copying cases depending on the actual type of destination array,
be it an array of KeyValuePair, DictionaryEntry, or object.
Fixes#444778.
svn path=/trunk/mcs/; revision=118841
* Dictionary.cs: fix ICollection<KeyValuePair<T>>.Remove and .Contains
to not only check if the key exists but if the associated value is the
good one as well. Fixes#444768.
svn path=/trunk/mcs/; revision=118838
* Dictionary.cs (Clear): Clear the linkSlots array as well, as
Enumerator.MoveNext () depends on it. Fixes#432441.
svn path=/trunk/mcs/; revision=114915
* Dictionary.cs: (ToTValue) allow null values to be added for non
value types TValues to the dictionary when using the
non generic IDictionary. Fixes#425693.
svn path=/trunk/mcs/; revision=112907
* String.cs: Dictionary: Do not change the index data when using the indexer for
an already existing index. This is somewhat illogical and breakes obscure code situations
svn path=/trunk/mcs/; revision=105870
2007-10-10 Juraj Skripsky <[email protected]>
* Dictionary.cs (Enumerator.MoveNext): Handle the case where we
had already reached the end. Fixes bug #332534.
svn path=/trunk/mcs/; revision=88534
* Dictionary.cs: Optimize and add implementation notes. Use a "mini-heap"
to store the linked lists instead of the regular heap. Split arrays of
structs into separate arrays to make the GC's life simpler (see bug 81879
for details). Make class serialization compatible with MS.NET.
* EqualityComparer.cs: Rename IEquatableOfTEqualityComparer<T> to
GenericEqualityComparer<T> to fix binary serialization compatibility
with MS.
svn path=/trunk/mcs/; revision=80341
* Dictionary.cs: An instance of Dictionary<TKey,TValue> is
supposed to throw a KeyNotFoundException when
the user attempts to retrieve the value associated with a key that
is not in the dictionary.
On the other hand, an instance of IDictionary is supposed to
return null in similar circumstances.
svn path=/trunk/mcs/; revision=73764
* Dictionary.cs: Speed up get_Item/set_Item/GetPrev () a bit. Increase capacity
specified by the user so 'capacity' elements can really be added without resizing.
svn path=/trunk/mcs/; revision=65005
* Dictionary.cs: Swap order of parameters to cmp.Equals () to improve
compatibility with MS.NET and strange Equals () implementations.
svn path=/trunk/mcs/; revision=62496
Speed up remove. Use 'dict[k]=v' as a self-tuning hint.
* Dictionary.cs (GetSlot): Move data-structure traversal to ...
(GetPrev): ... this. Returns the slot prior to the place we're
looking for, or null if that place is the head of the chain.
(Remove): Use it.
(this.set): Use it. Implement move-to-front on set.
* Dictionary.cs (ToTKey, ToTValue): New helpers to convert from
type 'object'.
(IDictionary.this, IDictionary.Add): Use them.
(IDictionary.Contains, IDictionary.Remove): If the types don't
match, do nothing.
In Test/System.Collections.Generic:
* DictionaryTest.cs (IDictionary_*): Add a few tests for the
IDictionary explicit implementation.
svn path=/trunk/mcs/; revision=55946
Fix to pass new nunit tests.
* Dictionary.cs (ShimEnumerator): New class. Implement the
requirement that ((IDictionary) foo).GetEnumerator ().Current has
type DictionaryEntry.
(IDictionary.GetEnumerator): Use ShimEnumerator.
(Enumerator.Current): Now has type KeyValuePair<TKey, TValue>.
(Enumerator.MoveNext): Use VerifyState.
(Enumerator.VerifyState): Move validation of 'current' field to ...
(Enumerator.CurrentSlot): ... this.
(Enumerator.Current, Enumerator.IDictionaryEnumerator.Entry):
Use CurrentSlot.
(CopyTo, ICollection.CopyTo): Use subtle reasoning to replace a
'>=' with a '>'. Don't throw an ArgumentException when
index==array.Length && Count==0.
(KeyCollection.CopyTo, ValueCollection.CopyTo): Likewise, and thus
obviate the need to check (dictionary.Count == 0).
In Test/System.Collections.Generic:
* DictionaryTest.cs: Remove NotWorking annotations.
(Empty_CopyTo, Empty_Values_CopyTo): Fix tests to check that
CopyTo from an empty dictionary does not throw an exception when
'index==array.Length'.
(PlainEnumeratorReturnTest): Check the type of 'Entry' property too.
svn path=/trunk/mcs/; revision=55781
* Dictionary.cs: Fixed ICollection.CopyTo to use DictionaryEntry. Fixed
Key and Value CopyTo not to throw exception if the dictionary is empty
(fix bug #77019).
svn path=/trunk/mcs/; revision=54616
Introduce some thread-safety by removing the modify-on-read
move-to-front heuristic.
* Dictionary.cs (_enumeratorGeneration, _enumerators): Remove.
(Count): Add internal property set. Invalidate enumerators when
Count is changed. Change all references of _usedSlots to Count.
(this): Invalidate enumerators when the value of some slot is
changed, even if the layout of the data-structure isn't modified.
(DoHash): Remove null-key check. All codepaths leading to this
function already have the check.
(GetSlot): Remove move-to-front heuristic.
(Remove): Update.
In Test/System.Collections.Generic:
* DictionaryTest.cs (FailFastTest1, FailFastTest2, FailFastTest3):
New tests to ensure that enumerators are invalidated on
modifications to the dictionary.
svn path=/trunk/mcs/; revision=46538
* IDictionary.cs: Use the same type parameter names than on MS.
* IDictionary.cs, Dictionary.cs: We don't need the `CLSCompliant'
attribute here.
svn path=/trunk/mcs/; revision=46477
* Dictionary.cs (_generation, _enumeratorGeneration, _enumerators):
New fields to implement fail-fast semantics. All code that
modifies the table increment _generation.
(GetSlot): Use _hcp to compare keys. Return the slot containing
the key, rather than the index. Avoid move-to-front heuristic
when there's an enumerator coursing through the table.
(this, Add, TryGetValue, ContainsKey, Remove): Update to change.
(Enumerator.Enumerator): Save the generation of the dictionary.
(Enumerator.Dispose): Inform dictionary that the enumerator is no more.
(Enumerator.MoveNext, Enumerator.VerifyState): Fail if the
dictionary has been modified.
In Test/System.Collections.Generic:
* DictionaryTest.cs (KeyValueEnumeratorTest): Add test for infloop
if dictionary is read while it's being enumerated.
svn path=/trunk/mcs/; revision=46370
* Dictionary.cs (EnumerationMode): Remove.
(Enumerator): Remove return type flag - legacy return is expected to
always return a DictionaryEntry
(Enumerator): Make constructor internal, it is not public on ms.net
beta 2
(Enumerator.MoveNext): Fix endless loop on enumerator use
(VerifyState): Added method to check state preconditions and throw
appropriate exceptions.
(KeyCollection,ValueCollection): Mark sealed to match ms.net beta 2
(KeyCollection.Enumerator._hostEnumerator): make exact struct type,
rather than boxing and using by interface
(KeyCollection.Enumerator.Dispose): use default to clear Enumerator
(ValueCollection.Enumerator._hostEnumerator): make exact struct type,
rather than boxing and using by interface
(ValueCollection.Enumerator.Dispose): use default to clear Enumerator
* EqualityComparer.cs (DefaultComparer, IEquatableOfTEqualityComparer):
Mark as serializable.
* DictionaryTest.cs (AddTest3): Added test of simple interaction with
struct dictionary
(AddDuplicateTest,IndexerGetNullTest,IndexerSetNullTest): Added tests
for exceptional cases to verify correct exceptions
(TryGetValueTest): check return value from TryGetValue
(KeyValueEnumeratorTest): Added test from verification of ms.net beta2
behavior for non-generic IEnumerator/IDictionaryEnumerator behavior
against Dictionary<>
(SerializationTest): Added test to utilize serialization routines.
svn path=/trunk/mcs/; revision=46200