ModernUO/Projects/UOContent
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
..
Accounting chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Assistants fix: Fixes missing ordinal string comparisons arguments. (#1431) 2023-07-23 20:12:38 -07:00
Commands fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Compression feat: Customize expansion and set maps on first boot (#1425) 2023-07-31 20:46:49 -07:00
Configuration chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Context Menus cleanup: Fixes bugs and cleans up code (#660) 2021-07-19 20:49:59 -07:00
Engines fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Gumps feat: Adds KR/EC client versions (No actual support yet). (#1506) 2023-09-18 23:53:18 -07:00
Holiday Stuff fix: Cleans up murder system (#1428) 2023-07-16 00:04:30 -07:00
Items fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Migrations feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00
Misc feat: Adds KR/EC client versions (No actual support yet). (#1506) 2023-09-18 23:53:18 -07:00
Mobiles fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Multis fix: Changes C# version to 11 (#1461) 2023-08-16 20:12:56 -07:00
Network feat: Adds a movement throttle system. Removes Fastwalk system. (#1511) 2023-09-27 20:53:22 -07:00
Regions fix: Fixes untamed creatures not entering houses (#1436) 2023-07-29 15:43:39 -07:00
Skills chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Special Systems fix: Renames WeightOverloading to StaminaSystem (#1495) 2023-09-06 18:58:45 -07:00
Spells fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Targets fix: Fixes the limitation on static tiles for harvesting (#1396) 2023-04-22 09:14:42 -07:00
Utilities fix: Fixes negative numbers in commands (#1343) 2023-02-17 00:34:24 -08:00
World Saves fix: Fixes missing ordinal string comparisons arguments. (#1431) 2023-07-23 20:12:38 -07:00
UOContent.csproj chore(deps): Bump MailKit from 4.1.0 to 4.2.0 (#1493) 2023-09-04 22:37:30 -07:00