ModernUO/Projects/Server.Tests/Tests
Kamron Batman a4cabe2fa4
fix: Optimizes FindItemsByType by removing allocations. (#1515)
### Summary
Container enumeration is in dire need of optimization. Thanks to @stefanomerotta for initiating this work with PR #1443. This PR handles a small part of what Stefan started. Also included are some bug fixes.

### Method Signatures

```cs
// Use with foreach without moving/deleting items
FindItemsByTypeEnumerator<T> FindItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use with foreach when moving/deleting items
QueuedItemsEnumerator<T> EnumerateItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiple times or queuing
PooledRefQueue<T> QueueItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiples times or manipulating elements without traversing
PooledRefList<T> ListItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)
```

* `FindItemsByType<T>` has changed from returning `List<T>` to `FindItemsByTypeEnumerator<T>` - This method is not safe to use in situations where an item may get consumed, deleted, or moved.

* `EnumerateItemsByType<T>` was added as a safe way to iterate and manipulate items.
  * **Note**: EnumerateItemsByType will _completely traverse the container_ before iteration starts because it uses `QueueItemsByType` under the hood.

* `QueueItemsByType<T>`  and `ListItemsByType<T>` was added to return a queue or list of items to iterate multiple times and manipulate the items. This isn't the most efficient since it uses a predicate and can result in 2 or 3 total iterations unnecessarily.

### Bug Fixes
- [X] Fishing had an error in the random check that may have caused slight bias.
2023-09-28 19:36:45 -07:00
..
Buffers feat: Customize expansion and set maps on first boot (#1425) 2023-07-31 20:46:49 -07:00
Client feat: Adds KR/EC client versions (No actual support yet). (#1506) 2023-09-18 23:53:18 -07:00
Collections fix: Fixes tests to use C# 11 syntax (#1462) 2023-08-17 00:58:44 -07:00
Geometry fix: Fixes Point3D.Parse (#1305) 2022-12-17 17:06:12 -08:00
Items fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Localization fix: Fixes localization test (#1046) 2022-06-04 12:09:19 -07:00
Maps feat: Customize expansion and set maps on first boot (#1425) 2023-07-31 20:46:49 -07:00
Network feat: Adds a movement throttle system. Removes Fastwalk system. (#1511) 2023-09-27 20:53:22 -07:00
Serialization fix: Fixes JSON TypeConverter so that it can deserialize full name types (#1466) 2023-08-21 21:25:09 -07:00
Text chore: Code Cleanup (#1239) 2022-11-10 22:49:25 -08:00
Timer feat(timers): Adds timer pooling, fixes timer related bugs, and changes timer api (#667) 2021-08-07 14:33:35 -07:00
Utility fix(core): Fixes string wrapping for houses (#717) 2021-08-22 10:01:01 -07:00
SerialTests.cs fix: Adds ISpanFormattable support to Serial (#1065) 2022-06-14 18:39:46 -07:00