Giter VIP home page Giter VIP logo

rock.collections's People

Contributors

nn--- avatar ondrejpetrzilka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rock.collections's Issues

OrderedDictionary: Initialize not called on new, empty instance causes crash when enumerating

m_firstOrderIndex is left in uninitialized state (not -1) when a new instance is created, Initialize is only called when capacity > 0 in constructor, or when adding a new item with null buckets.

The .NET dictionary will simply iterate on the size of the enumerator, but in your case, you check m_firstOrderIndex, which since it is 0 in the uninitialized state, results in a crash trying to get the first element in an empty collection.

var dict = new OrderedDictionary<string,string>();
foreach (var entry in dict) { /* boom */ }

Our fix is just to change the ctor line to:
if (capacity >= 0) Initialize(capacity);

A better fix would preserve your desire for lazy use of memory, and enumerate on the size, similar to the stock .NET.

Enumerator bug when accessing last element

When accessing the last enumerator element using Enumerator.Current I get an exception, because the implementation can not distinguish between valid enumerator at last element and invalid enumerator advanced past the last index.

I have introduced -2 marker to solve this, and now use named const variables for these markers.

I have implemented a fix in koliyo@1cead3d

Only for OrderedDictionary at the moment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.