Giter Club home page Giter Club logo

swordfishcollections's People

Contributors

fjch1997 avatar longnguyen2004 avatar stewienj avatar vslee 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  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  avatar  avatar  avatar  avatar  avatar

swordfishcollections's Issues

Add GetOrAdd functions to ConcurrentObservableDictionary to match ConcurrentDictionary

The overloads are listed here https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd?view=net-7.0

Overloads

GetOrAdd(TKey, Func<TKey,TValue>) Adds a key/value pair to the ConcurrentDictionary<TKey,TValue> by using the specified function if the key does not already exist. Returns the new value, or the existing value if the key exists.
GetOrAdd(TKey, TValue) Adds a key/value pair to the ConcurrentDictionary<TKey,TValue> if the key does not already exist. Returns the new value, or the existing value if the key exists.
GetOrAdd(TKey, Func<TKey,TArg,TValue>, TArg) Adds a key/value pair to the ConcurrentDictionary<TKey,TValue> by using the specified function and an argument if the key does not already exist, or returns the existing value if the key exists.

Wrong event fired on `ConcurrentObservableSortedSet.Remove`

public bool Remove(T value)
{
bool wasRemoved = false;
DoReadWriteNotify(
() => _internalCollection.Count,
(index) =>
{
var newCollection = ((ImmutableSortedSet<T>)_internalCollection).Remove(value);
wasRemoved = newCollection != _internalCollection;
return newCollection;
},
(index) => wasRemoved ? new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, value, index) : null
);
return wasRemoved;

This should be NotifyCollectionChangedAction.Remove, not NotifyCollectionChangedAction.Add

want to use Swordfish.NET.CollectionsV3 in WinForms

I use WPF in WinForms . Before , i used CollctionsV2 and modeified the DispathcerQueueProcesser.cs so that it can run in WinForms , but the the UI and backgroundwork often freeze . I can't figure out why it freeze. So i want to use ColltionsV3 , but i don't know how to modify it so that it can be used in WinFroms. Any idea?

ConcurrentObservableDictionary is non performant because it also acts like a List

ConcurrentObservableDictionary is not a straight wrapper around an ImmutableDictionary, instead it has a dual personality where it can be used as a Dictionary or a List. This behaviour stems from a very old requirement that has long been forgotten. Unfortunately this behaviour also has significant performance penalties. The ConcurrentObservableDictionary class should be moved to ConcurrentObservableDictionaryList, and a proper ConcurrentObservableDictionary should be created that works the same way as other classes list ConcurrentObservableHashSet.

This change will be a breaking change for anyone using ConcurrentObservableDictionary as a List. I'm wondering how many people this will affect?

AddRange method throw exception (casting issue)

Hi,

I'm trying to use the AddRange method of ConcurrentObservableDictionary, but it always fail, due to a casting.

Unhandled exception. System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' to type 'System.Collections.IList'.
   at Swordfish.NET.Collections.ConcurrentObservableDictionary`2.<>c__DisplayClass4_0.<AddRange>b__2(Int32 index)
   at Swordfish.NET.Collections.ConcurrentObservableBase`2.BodyReadWriteNotify[TRead](TRead readValue, Func`2 write, Func`2[] changes)
   at Swordfish.NET.Collections.ConcurrentObservableBase`2.DoReadWriteNotify[TRead](Func`1 read, Func`2 write, Func`2[] changes)
   at Swordfish.NET.Collections.ConcurrentObservableDictionary`2.AddRange(IEnumerable`1 pairs)
   at MyMethodCallingAddRange() in /where/my/code/is.cs:line 42

I tried with some variant of a IDictionnary (normal, default concurrent, concurrent from your library).

Temporary fix: I call AddRange with a IList<KeyValuePair<string, string>>

[New Feature Request] Add new constructors that take IEnumerable<T> or List<T>

Basically I'm using ConcurrentObservableCollection as a drop-in replacement for ObservableCollection, and was surprised that it doesn't provide constructors that take some kind of IEnumerable. This is mostly a nice to have that allows initializing code to be moved out of the constructor, like this:

public ConcurrentObservableCollection<int> MyCollection { get; init; } = new(new int[4]);

General goals, motivation and functionality

As you are the dev it would be great to read why and how you have done this ... and maybe why.
Differences to BCL and so on.

So would be great to extend the readme a bit :)

Proposal: Have a directly bindable BindableCollectionView

Currently you can't directly bind to the CollectionView. Have a BindableCollectionView class. This wraps an immutable collection, fires INotifyCollectionChanged with a Reset action and gets the Synchronization context when it is created.

Does not run in PCL Library

Hi guys,

This set of collections seems awesome. Any chance you will build them so they work in PCL Libraries? Would love to give them a try in Xamarin.Forms.

Thanks and keep up the great work.

Patrice

Is a concurrent sorted set planned ?

I would need a thread safe sorted set as a cache inside my asp.net app.

Want to get a set of objects based on an enumerable in a specific sort order.

Things that could be done

This is an awesome library. Been using it for a year now so it feels right to contribute

  1. Make everything serializable
  2. Write a nuspec file and push it to NuGet. Replace the old unofficial one.
  3. Make it portable
  4. All the collection under Swordfish.NET.Collections does not implement INotifyPropertyChanged to signal Count change
  5. Remove log4net it just doesn't make sense
  6. Properly implement ICollection.SyncRoot so we can use something like the following
ConcurrentObservableCollection<MyObject> collection = GetSomeCollection();
Predicate<MyObject> predicate = GetSomePredicate();
lock (((System.Collections.ICollection)collection).SyncRoot)
{
    if (collection.Any(i => predicate(i)))
        collection.Add(GetMyObject());
}

This is something similar to ConcurrentDictionary.TryAdd()

I already did 2, 5 and part of 1 in my forked repo. Will put more work on it if people agree and consider them to be useful

V3 ConcurrentObservableCollection with WPF ListCollectionView

Anybody have any ideas on how to get this collection type to play nicely with the ListCollectionView? Currently have a WPF ListView Binding to the CollectionView property of the collection, and creating a ListCollectionView to add live sorting and live filtering on via CollectionViewSource.GetDefaultView(MyCollection.CollectionView)

I would guess that since we are not actually binding to a collection, but rather to a property instead that the live filtering and sorting are not being applied.
I've tried catching the property changed event and manually calling ListCollectionView.Refresh() to no avail.

Directory and Project structure is a bit adhoc on this project

The directory and project structure needs to be tidied up a bit on this project.
There's a mix of some utility stuff in the Swordfish.NET project that is stored in the General directory.

Version 2 of Swordfish.NET.Collections is in the Collections directory.
Version 3 of Swordfish.NET.Collections is in the CollectionsV3 directory.
There's some examples and tests in the ExamplesAndTests directory.

Would be good to keep V3 of the Collections a Portable Class Library. So anything WPF specific should go into another library. Same with the utility stuff.

Will also need a Documentation directory.

Any major rearrangement should be timed to reduce disruption to branches that are in active development, e.g. the PCL branch being worked on by @fjch1997

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.