Comments (8)
To be precise:
I use C5.HashDictionary<K, int>.Values
On second call to Values
, all int
values are 0
(zero)
from c5.
Could you supply a piece of code to reproduce the bug?
Is the bug present in previous versions?
from c5.
Test
Implementation under test
Bug was not present in 2.4.5828.26833
from c5.
@ondfisk
Just add two or three Key-Value-Pair (T, int) with different int values.
Get the .Values, everything is OK.
Get the .Values again and all int values are 0.
from c5.
I have found the change that caused the issue:
inside: internal class KeysCollection : CollectionValueBase<K>, ICollectionValue<K>
@ Dictionaries.cs
public override SCG.IEnumerator<V> GetEnumerator()
{
//Updatecheck is performed by the pairs enumerator
foreach (KeyValuePair<K, V> p in pairs)
yield return p.Value;
}
became
public override SCG.IEnumerator<V> GetEnumerator()
{
//Updatecheck is performed by the pairs enumerator
_internalEnumerator.UpdateReference(_pairs);
return _internalEnumerator;
}
The new enumerator:
internal void UpdateReference(ICollection<KeyValuePair<K, V>> list)
{
_internalList = list;
Current = default(V);
}
public override bool MoveNext()
{
ICollection<KeyValuePair<K, V>> list = _internalList;
if (_internalEnumerator == null)
_internalEnumerator = list.GetEnumerator();
if (_internalEnumerator.MoveNext())
{
Current = _internalEnumerator.Current.Value;
return true;
}
Current = default(V);
return false;
}
And within that: (in MoveNext)
if (_internalEnumerator == null)
_internalEnumerator = list.GetEnumerator();
Is only ever called once and never updated.
if you add _internalEnumerator = list.GetEnumerator();
to UpdateReference
, it works again.
I assume that its supposed to be linqy and update automagically, but its not (why this is a comment, and not a PR, I don't understand the intended behavior).
I noticed that the Keys collection resolves differently at runtime. Values uses the ValuesCollection and ValueEnumerator resolving to C5.TreeSet<C5.KeyValuePair<,>.Enumerator (which has the old stamp value of '0'), but Keys resolves to C5.SortedDictionaryBase<, >.SortedKeysCollection.KeyEnumerator. So I assume this bug would also affect Keys if Keys used the KeysCollection in the same way as the Values uses ValuesCollection.
I hope this helps in solving the problem.
from c5.
It certainly does. Thanks.
I will look into it ASAP.
I have hidden the buggy NuGet packages.
from c5.
Thanks
from c5.
I've pushed a new version to NuGet. Please verify that the issue has been resolved
from c5.
Related Issues (20)
- Traversal algorithm should be part of this kind of library
- Why C5 is not CLS-compliant? HOT 1
- Proposed documentation improvements HOT 4
- Why is the file version different to the assembly version? HOT 1
- Unhandled Exception in Unity 5 HOT 2
- Why does TreeSet not implement SCG.ISet? HOT 3
- Inconsistent/wrong implementations of Keys property by guarded dictionaries HOT 1
- Nuget NetStandard/Core Update HOT 4
- Add AppVeyor CI for PR validation to this project HOT 1
- Doesn´t work on Visual Studio 2015 HOT 2
- Error at building project C5 in Visual Studio 2017 15.1 26403.0 Enterprise HOT 1
- State of project? HOT 10
- Time complexity of SortedArray<t> indexing HOT 1
- Single writer multiple readers pattern with snapshots HOT 2
- Inconsistent default constructors HOT 5
- compatibility with Unity HOT 7
- Add range variants of FindMin() and DeleteMin()
- Any modern documents? HOT 2
- Please update package on NuGet HOT 4
- TreeList<T>? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c5.