-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Collections.Generic ISet<T>
and IDictionary<T>
(Fixes #53)
#93
base: master
Are you sure you want to change the base?
Conversation
No, what I meant was that the |
On 4 Jan 2020, at 16.55, Shad Storhaug <[email protected]<mailto:[email protected]>> wrote:
You mean, using the indexer set[i] = … where i is an integer?
Having this indexer on ISet is an abominable design mistake in the .Net library, and I think it should throw an exception on HashSet and similar. What does it do on SCG.HashSet?
No, what I meant was that the SCG.HashSet<T> has an IndexOfInternal(TKey) method and a way to delete an item internally by index.
Strange, I don’t see any (documentation of) such a method on either SCG.HashSet<T> or SCG.ISet<T>.
In any case I believe the best way to implement it is by a method that throws a suitable exception, with a message such as “Not implemented”.
Peter
|
You won't find any documentation, because as I mentioned, the method is intenal: There is also an internal way to delete a slot by index after determining which indices need removal:
Since this is the slow path that happens whenever the equality comparers don't match (which is probably 70-80% of the time), it would mean that all of the set operations would throw an exception 70-80% of the time. Of course, if there is no way to get the index of an item or delete an item by index, this could be implemented by wrapping each item in a structure with a bit to track the items, but that would be a lot slower than using a I was hoping you had a more clever lower-level way to complete this than what Microsoft did. But whatever the case, to me it makes more sense to provide the basic tests and a direction to go than to provide a broken implementation or one that is unreasonably slow. Since it is not part of the PR, you can either use your knowledge of the inner workings of C5's |
|
Do you mean hide all of the It would be useful to provide the rest of the set operations ( Either way it feels like |
No I mean hide the |
@NightOwl888: are you working on the changes mentioned above? |
I haven't had a chance to get to it yet, and it might be awhile until I have the time. No objections if you want to jump ahead and do it yourself. |
This PR addresses #53:
SCG.ISet<T>
onTreeSet<T>
SCG.IDictionary<K, V>
onDictionaryBase<K, V>
I also attempted to implement
SCG.ISet<T>
onHashSet<T>
, but since it seems to be missing a way to get and delete items by index, I am not sure how to proceed. Here is the (non compiling) attempt, in case you want to try to complete it:Redundant Behavior
Do note that the
AddAll
,ContainsAll
RetainAll
, andRemoveAll
methods are now redundant withUnionWith
,IsSupersetOf
,IntersectWith
, andExceptWith
, respectively.Options
AddAll
,ContainsAll
RetainAll
, andRemoveAll
UnionWith
,IsSupersetOf
,IntersectWith
, andExceptWith
by using explicit interface declarationsPerformance
Most of the
ISet<T>
methods were reverse engineered fromSCG.HashSet<T>
, but it may be possible to implement some of the methods at a lower level for better performance - I didn't look into it.