Skip to content

Commit

Permalink
4.0.0 rewriting & speed up! (#79)
Browse files Browse the repository at this point in the history
* Code refactoring & rewriting
* Use Parallel and ConcurrentBag
* Force Stars filter;
* Better serialization/deserialization & encounter handling
* Use records and struct; less garbage collector jobs
* Don't waste memory by producing unwanted results; early filter returns on entity generation
* More efficient seed checker
* Added a splash screen while the program launcher is loading
* More robust reward checker
* Added project tests
* RemoteExecutor is now its own project
* Misc fixes & improvements
* Added compatibility with the latest PKHeX thanks @foohyfooh 

Thanks @Lusamine and @santacrab2 for support and suggestions :)
  • Loading branch information
Manu098vm authored Mar 19, 2024
1 parent 8f27378 commit 3311897
Show file tree
Hide file tree
Showing 91 changed files with 4,601 additions and 4,656 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Alternatively, feel free to contact me on my [Discord Server](https://discord.gg
## License
![gplv3-with-text-136x68](https://user-images.githubusercontent.com/52102823/199572700-4e02ed70-74ef-4d67-991e-3168d93aac0d.png)

Copyright © 2023 Manu098vm
Copyright © 2024 Manu098vm

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
127 changes: 127 additions & 0 deletions TeraFinder.Core/Classes/ConcurrentList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.ComponentModel;

namespace TeraFinder.Core;

public class ConcurrentList<T> : ConcurrentBag<T>, IBindingList
{
public bool IsFinalized { get; private set; } = false;

private ImmutableArray<T> _binding;

public void FinalizeElements()
{
_binding = [.. this];
IsFinalized = true;
}

public new void Clear()
{
base.Clear();
_binding = _binding.Clear();
IsFinalized = false;
}

object? IList.this[int index]
{
get => GetElement(index);
set => throw new AccessViolationException("The List can not be edited.");
}

private T GetElement(int index)
{
if (IsFinalized)
return _binding[index];

throw new AccessViolationException("The List has not been finalized.");
}

bool IBindingList.AllowEdit => IsFinalized;
bool IBindingList.AllowNew => !IsFinalized;
bool IBindingList.AllowRemove => false;
bool IBindingList.IsSorted => false;

ListSortDirection IBindingList.SortDirection => throw new NotImplementedException();
PropertyDescriptor? IBindingList.SortProperty => throw new NotImplementedException();
bool IBindingList.SupportsChangeNotification => false;
bool IBindingList.SupportsSearching => IsFinalized;
bool IBindingList.SupportsSorting => false;

bool IList.IsFixedSize => false;
bool IList.IsReadOnly => false;

event ListChangedEventHandler IBindingList.ListChanged
{
add => throw new NotImplementedException();
remove => throw new NotImplementedException();
}

int IList.Add(object? value)
{
#pragma warning disable CS8600
#pragma warning disable CS8604
Add((T)value);
#pragma warning restore CS8600
#pragma warning restore CS8604
return 0;
}

void IBindingList.AddIndex(PropertyDescriptor property)
{
throw new NotImplementedException();
}

object? IBindingList.AddNew()
{
throw new NotImplementedException();
}

void IBindingList.ApplySort(PropertyDescriptor property, ListSortDirection direction)
{
throw new NotImplementedException();
}

void IList.Clear() => Clear();

bool IList.Contains(object? value)
{
throw new NotImplementedException();
}

int IBindingList.Find(PropertyDescriptor property, object key)
{
throw new NotImplementedException();
}

int IList.IndexOf(object? value)
{
throw new NotImplementedException();
}

void IList.Insert(int index, object? value)
{
throw new NotImplementedException();
}

void IList.Remove(object? value)
{
throw new NotImplementedException();
}

void IList.RemoveAt(int index)
{
throw new NotImplementedException();
}

void IBindingList.RemoveIndex(PropertyDescriptor property)
{
throw new NotImplementedException();
}

void IBindingList.RemoveSort()
{
throw new NotImplementedException();
}
}
Loading

0 comments on commit 3311897

Please sign in to comment.