DO NOT DEAL WITH THIS MEMBER
So I'm fairly well into my project and I'm very rarely getting errors now to where my listbox is giving null values (I believe its because of thread clashing if that's a thing), and I'm looking to try to find a way to remove duplicates.
I've looked up some tuts but none seem to ACTUALLY do anything.. There's code that looks like it'd do something, but nothing would happen.
At this point I have no raw code for the process but what I'm looking to do:
Listbox full of items -> click button called remove duplicates -> it removes duplicated items and the rest remain the same..
I don't care for a full spoon feeding, just a little help to further my knowledge. Thanks!
Lotta blood to let, peace to make, give a fuk about a check
DO NOT DEAL WITH THIS MEMBER
(Feb 25, 2017 07:59 PM)BahNahNah Wrote: You could use Distinct
https://msdn.microsoft.com/en-us/library....110).aspx
I don't think that would be the way to go around this.
DO NOT DEAL WITH THIS MEMBER
(Feb 26, 2017 06:53 PM)Gørilla Wrote: I don't think that would be the way to go around this.
Prevent adding dupes in the first place or just don't use a listbox at all as you seem to use it for a functionality and not just GUI
PM me if you want any input
DO NOT DEAL WITH THIS MEMBER
(Feb 26, 2017 06:58 PM)Closed User Wrote: Prevent adding dupes in the first place or just don't use a listbox at all as you seem to use it for a functionality and not just GUI
PM me if you want any input
Would you suggest using a rich text box or something?
DO NOT DEAL WITH THIS MEMBER
(Feb 26, 2017 07:00 PM)Gørilla Wrote: Would you suggest using a rich text box or something?
I would suggest using just a list
ex.
Dim stringList as New List(Of String)
stringList.Add("thisisastring")
stringList.Add("thisisanothastring")
That would make everything way more smoother and as I read your past issues(Multithreading) it'll speed up the process a ton by doing this
Tasks.Parallel.ForEach(stringList, Function(line As String)
'Operation here
End Function)
(Feb 26, 2017 06:53 PM)Gørilla Wrote: I don't think that would be the way to go around this.
Depending on how the items are added, it could be one of the better ways. If you aren't going to grab by index, using a HashSet to prevent duplicates in the first place works too.
Whatever you do, don't use Contains on a List when you're adding a large amount in a short time span.
(Feb 25, 2017 07:59 PM)BahNahNah Wrote: You could use Distinct
https://msdn.microsoft.com/en-us/library....110).aspx
This is exactly the way to go.
(Feb 27, 2017 12:02 PM)Owl Wrote: How come nobody recommended hashset? Handles everything.
https://msdn.microsoft.com/en-us/library....110).aspx
It was mentioned in multiple forms. Actually, only 1 person didn't suggest the use of a HashSet.
DO NOT DEAL WITH THIS MEMBER
(Feb 27, 2017 01:49 PM)SL x TnT Wrote: It was mentioned in multiple forms. Actually, only 1 person didn't suggest the use of a HashSet.
I will look into using this:)
DO NOT DEAL WITH THIS MEMBER
If they are strings you can use string.IsNullOrEmpty. Also, it is better to prevent duplicates from entering (ie. using a HashSet) than filtering them afterwards.
DO NOT DEAL WITH THIS MEMBER
(Feb 27, 2017 05:31 PM)Ninja Wrote: If they are strings you can use string.IsNullOrEmpty. Also, it is better to prevent duplicates from entering (ie. using a HashSet) than filtering them afterwards.
I will see if I can implement this into my project:).
I'm not a .NET developer so my answer might not be accurate but should give you some ideas.
First of all when you add a large list, use a stringlist first before you output it to your GUI.
This way you can edit the list like removing the duplicates in the first place.
In Delphi (that's what I program with) a stringlist has a property which lets you set a duplicate flag that avoids adding duplicates in the list. I found this answer online: http://stackoverflow.com/questions/47752...in-c-sharp
After the list is ready, then output the results, this way it is the fastest.
Good luck and enjoy developing :)
DO NOT DEAL WITH THIS MEMBER
(Feb 28, 2017 03:34 AM)Snify3000 Wrote: I'm not a .NET developer so my answer might not be accurate but should give you some ideas.
First of all when you add a large list, use a stringlist first before you output it to your GUI.
This way you can edit the list like removing the duplicates in the first place.
In Delphi (that's what I program with) a stringlist has a property which lets you set a duplicate flag that avoids adding duplicates in the list. I found this answer online: http://stackoverflow.com/questions/47752...in-c-sharp
After the list is ready, then output the results, this way it is the fastest.
Good luck and enjoy developing :)
I think this relates to vb.net as well. I'm going to look into the hash reference they were talking about when I fix up my program today:).
|